/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-08-28
*/
var babel=function(a){if(a.loadLib)return a;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto="#000000";a.maxenta=a.magenta="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise="#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert="#00ff00";
a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho="#ff0000";a.pink=a.rosa=a.arrosa=a.rose="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro="#404040";a.gris=a.gray=a.grisa=a.cinza="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=
"#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a.colour=a.color=a.kolorea=a.couleur=a.cor="color";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]=
"sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=
a.konfig=a["configura\u00e7\u00e3o"]="config";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=
a["preencher-"]="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=
a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=
a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=
"language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";
a.texto=a.text=a.testu=a.texte="text";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=
a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=
a["eixo-y"]="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";
a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto=
"auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=
a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=
a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=
a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=
a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=
a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=a.zentratu=a["centr\u00e9e"]=a.centrado="center";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.tipo_de_macro=a.macro_type=a.tipus_de_macro=a.makro_mota=
a.type_de_macro=a.tipo_de_macro=a.tipo_de_macro=a.tipus_de_macro="macro_type";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=a.filas_norte=a.linhas_norte=a.files_nord="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud="rowsSouth";a.ancho_este=a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=
a.ancho_oeste=a.largura_oeste=a.ample_oest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]="initAnimation";a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=
a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=
a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=
a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=
a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=
a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]="activeif";a.rotfin=a.finrot=a.bukrot="endrot";a.posfin=
a.finpos=a.bukpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";
a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte="onlyText";a.evaluar=a.evaluate="evaluate";a.respuesta=a.answer="answer";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=
a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text="border";a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.malla=a.mesh="mesh";a.local=a.Local="local";a.loadLib=!0;return a}(babel||{}),descartesJS=function(a){function e(a,b,d){a.fillStyle=
"#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);g(a,b,d.controls)}function g(a,b,d){for(var h,c=d.length-1;0<=c;c--)h=d[c],a.drawImage(h.getScreenshot(),b.offsetLeft+h.x,b.offsetTop+h.y)}if(a.loadLib)return a;var k=2*Math.PI,b=360/k,c=k/360,d=Math.floor,j,f,r,m,l,q,p,t,n,u;a.rangeOK=1;a.extend=function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var d in b.prototype)b.prototype.hasOwnProperty(d)&&(a.prototype[d]=b.prototype[d]);a.prototype.uber=
b.prototype};a.radToDeg=function(a){return a*b};a.degToRad=function(a){return a*c};a.convertFont=function(a){if(""==a)return a;j=a.split(",");f="";"bold"==j[1].toLowerCase()?f+="Bold ":"italic"==j[1].toLowerCase()||"italics"==j[1].toLowerCase()?f+="Italic ":"bold+italic"==j[1].toLowerCase()&&(f+="Italic Bold ");f+=j[2]+"px ";r=j[0].split(" ")[0].toLowerCase();return f="serif"===r||"times new roman"===r||"timesroman"===r||"times"===r?f+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===
r||"arial"===r||"helvetica"===r?f+"Arial, Helvetica, 'Droid Sans', Sans-serif":f+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,h,c,f,j,e){a.lineWidth=e||1;a.strokeStyle=j||"black";j=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(d(b)+j,d(h)+j);a.lineTo(d(c)+j,d(f)+j);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;m=a.evalExpression(b);l=d(255*m[0][0]);q=d(255*m[0][1]);p=d(255*m[0][2]);t=1-m[0][3];return"rgba("+l+","+q+","+p+","+t+")"};a.getFeatures=
function(){a.hasJavaSupport=navigator.javaEnabled();var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||b.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;b=document.createElement("canvas");a.hasCanvasSupport=b.getContext&&b.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));var d,h,c,f,j,e,k,l,n;Number.prototype.originalToFixed=
Number.prototype.toFixed;Number.prototype.toFixed=function(a){if(20>=a)return this.originalToFixed(a);a=0>a?0:parseInt(a);d=this.toString();j=d.indexOf("e");h=d.indexOf(".");if(-1!==j)if(e=d.split("e"),l="-"===e[0][0]?"-":"",k="-"===l?e[0].substring(1):e[0],n=parseInt(e[1]),0>h+n){var b=l+"0.",g;g=Math.abs(h+n);g=Array(g+1).join("0");d=b+g+k.replace(".","");h=1}else k=k.replace(".",""),d=l+k+Array(n-k.length+2).join("0"),h=-1;c="";if(-1===h)return 0<a&&(c="."),c+=Array(a+1).join("0"),d+c;f=d.length-
h-1;if(f>=a)return 0<a?d.substring(0,h+1+a):d.substring(0,h);b=0;for(a-=f;b<a;b++)c+="0";return d+c}};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],n=a.pageX,u=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(n=a.pageX,u=a.pageY):(n=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,u=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);
return{x:n,y:u}};a.getTextWidth=function(b,d){a.ctx.font=d;return a.ctx.measureText(b).width};var h=document.createElement("span");h.appendChild(document.createTextNode("\u00c1p"));var s=document.createElement("div");s.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var v=document.createElement("div");v.setAttribute("style","margin: 0; padding: 0;");v.appendChild(h);v.appendChild(s);var y={};a.getFontMetrics=function(a){if(y[a])return y[a];h.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");
document.body.appendChild(v);var b={};v.getBoundingClientRect?(s.style.verticalAlign="baseline",b.ascent=s.offsetTop-h.offsetTop,b.h=v.getBoundingClientRect().height||0):(s.style.verticalAlign="baseline",b.ascent=s.offsetTop-h.offsetTop,s.style.verticalAlign="bottom",b.h=s.offsetTop-h.offsetTop);b.descent=b.h-b.ascent;b.baseline=b.ascent;document.body.removeChild(v);return y[a]=b};a.getFieldFontSize=function(a){a=Math.min(50,a);return a=24<=a?Math.floor(a/2+2-a/16):20<=a?12:17<=a?11:15<=a?10:9};a.getScreenshot=
function(){var b=a.apps[0],d,h=document.createElement("canvas"),c=new Image;if(b){h.setAttribute("width",b.width);h.setAttribute("height",b.height);for(var f=h.getContext("2d"),j=0,k=b.spaces.length;j<k;j++)d=b.spaces[j],"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<b.northSpace.controls.length&&e(f,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&e(f,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&
e(f,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&e(f,b.westSpace.container,b.westSpace);c.src=h.toDataURL("image/png")}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g;a._externalFilesContent={};a.openExternalFile=function(k){if(a._externalFilesContent[k])return a._externalFilesContent[k];e=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(c){b=!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(d){try{b=
new ActiveXObject("Microsoft.XMLHTTP")}catch(j){b=!1}}g=b;g.open("GET",k,!1);try{g.send(null),e=g.responseText,e.match(String.fromCharCode(65533))&&(g.open("GET",k,!1),g.overrideMimeType("text/plain; charset=ISO-8859-1"),g.send(null),e=g.responseText)}catch(f){console.log("Error to load the file :",k),e=null}return e};a.addExternalFileContent=function(e,b){a._externalFilesContent[e]=b};return a}(descartesJS||{}),descartesJS=function(a){function e(a){c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};
c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1),"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1)));"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1),c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1)));"*"===c.charAt(0)&&"*"!==c.charAt(c.length-1)?c=c.substring(1)+"$":"*"!==c.charAt(0)&&"*"===c.charAt(c.length-1)?c="^"+c.substring(0,c.length-1):"*"!==c.charAt(0)&&"*"!==c.charAt(c.length-
1)?c="^"+c+"$":"*"===c.charAt(0)&&"*"===c.charAt(c.length-1)&&(c=c.substring(1,c.length-1));c=c.replace(/\?/g,"[\\S\\s]{1}");a.regExp=c;return a}function g(a,b){c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=c.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function k(a,
b,d){b=parseFloat(b);r=a.expr[0];m=a.expr[1];l=d.evalExpression(r.expr);q=d.evalExpression(m.expr);p="("==r.type;t="["==r.type;n=")"==m.type;u="]"==m.type;return(p&&b>l||t&&b>=l)&&(n&&b<q||u&&b<=q)?1:0}function b(a){return a.toString().replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,
"N")}if(a.loadLib)return a;var c,d,j,f,r,m,l,q,p,t,n,u;a.buildRegularExpresionsPatterns=function(a,b){"("===a.charAt(0)&&(")"===a.charAt(a.length-1)&&-1===a.indexOf(","))&&(a=a.substring(1,a.length-1));a=a.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|");for(var f=0,k=a.length;f<k;f++){d=a[f].split("&");j=[];for(var l=0,n=d.length;l<n;l++)c=d[l],-1!==c.indexOf(",")&&("("===c.charAt(0)||"["===c.charAt(0))&&(")"===c.charAt(c.length-1)||"]"===c.charAt(c.length-1))?j.push(g(c,b)):j.push(e(c));
a[f]=j}return a};a.escorrecto=function(h,c,j,e){j=j||a.externalEvaluator;e=e||a.buildRegularExpresionsPatterns(h,j);c=b(c);h=0;for(var l=e.length;h<l;h++){d=e[h];f=!0;for(var n=0,g=d.length;n<g;n++)f=d[n].regExp?f&&!!c.match(b(d[n].regExp),"i"):f&&k(d[n],c,j);if(f)return 1}return 0};a.esCorrecto=function(h,j,e,l){e=e||a.externalEvaluator;l=l||a.buildRegularExpresionsPatterns(h,e);h=0;for(var n=l.length;h<n;h++){d=l[h];f=!0;for(var g=0,m=d.length;g<m;g++)(c=d[g].regExp)?(d[g].ignoreAcents&&(j=b(j),
c=b(c)),d[g].ignoreCaps&&(j=j.toLowerCase(),c=b(c).toLowerCase()),f=f&&!!j.match(c)):f=f=f&&k(d[g],j,e);if(f)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABHNCSVQICAgIfAhkiAAACpVJREFUaIHtWm1sU9cZfu61iUYnPP/bJgdhhDbFkVYcCrR0tLHXrVNL01wvgUJDh820tivrkpQQtpEvA4HGhDoe/dCmNfbaVa1WKszX2oUO3xC0OHESm9Hi/FhloyQq1aY5OGgq8ce7H9f3xI7txKFsdKyPdHSPz8dzz33Oe77eY46IVBzHXcUXuOkgIo4DQABwuucUeJ4Hz/NQKBTgeQUUPA9ekXryPDiOB89x4DgO4DiZBQQCJQlJSiKZlEIikZCeyQQSiSSSyQTLS1KSlSciuTEsfjtgY+UmAAAHgGRxFQqFFHjFTFyhkPJ4RUpkDhzHp+ubEiclbFISM5FIhfR4IlPkZDLJhE0X+nbBxspNUALIFFehhDLjKYWTx0/B4/FgcHAQU9GpDKIlqiVYu3YtjN8xouLRR5BIKsDzcalDEjw4cJD6cgaUJGkkANIY4iRxR3x+uN9xIxgMZpTX6XQQqgSsWlNW0Md9Xng4APSns+9BqVQyUZVKpRQUSvSK52B73oaJiYmCGqTRaND4i0aUl9+PeCKBRCKOeDwVEnHE4wlm4emW/PHExzjS9SJGg6MAAIPBAL1eDwAIBAIQRREAUKIrwY7aHfja17+a8/1XPv4ELzle+lzwbKzcJAn8fu8ZKBXKGWGVi7BIqURrcxvcx9ysglqthiAI0Gq1KC8vBwD09vYiHA7D7XZjcnKSlRVMAhoad2LxHYsRj8cRi8cRj8cQj8czpwxK4mrkKn769LOIRqMQBAF2ux1arTajseFwGPX19XC73VCpVGi3tWd91LXoNdTuqPvc8MjzMJ3tO0t9/eeo39dPQwEfXfggQIJJIEiDl9RqNbW1tVEkEqG54HQ6Sa1Ws3oluhI6399HQ4Eh8g71U1//OfL0naUzYg+99+d36XTPKTrx7nHS6XQEgMxmcwafzDP7HTL328f/kBFKdCU5eRx2Oz3+2ObPxDM2Nkbe/n7y9vfT2NhYQTwAiAcARWoOVioUUCoyLVev18Pv96O1tRVqtTprGKTDbDYjFAqxoTQaHEWn7XDGXM6zHYm0G/F5fQgGgxAEAY27ds3JL79DEASMBkcx4vOz9BGfH6PBUawqK8O996xj6b/q6sLzNhtOnj6N3Q27MD4+XhBPent+/9prMKy/DzWbt6Bm8xYY1t+HMz09c/Kkg/q8feQd8tLIhWFyHHEwy9Hr9fNabS5EIhHS6/WMx/Gig0b+OkIDw1467+0jz3nJit99/4+kK5WsNxQKFcwfCoUIAOl0OmYt8igo+cY3acUyLZV/ez09/eMnCQC1tbXRwQMHCQAdffvtgnjk9nj7+yW+u9fRj7ZZqHFnA61YpqUVy7TksNvz8uSwYMmKbc/bAEjzrdPpnNdqc0GtVsPj8bC6toO21F46ZcFcak/N8wheCsJgMGTNcRaLhVm5xWLJyNNqtTAYDBkrezAo8VRUVGDjpk0YHx/HmZ4erFimxb+mrmHrE1tx6cMPUVVdXRCPVqtFNBpF0H8RAFAp/AC/dXWjo/MQ9rQ0AwBc3c68PDJ4AKlhK23F5N1CXV0dG+o3ArVaDbvdDgCYmJjAyROn2IFFEplj27Rc73G5XDnjMnLV0ev1sB3uxEFbB954601UVVfjo8th2A53YunSpXB1OxG8dKkgHhntL0gG95vfvcrSvvfggwCAaDSKT65cycsDpASWrcnj8QCQxKmtrWWFRFGEyWSC0WiE0WiE1WrNm9fV1cXyzGYzs2LPWU+a9XLg+BmB/xO4+5570NF5CGNjY2jc2YCyb92Jd44eRcXDG1CzeQubQ+eCSqWCw+HAHaoleOWVV3KW+fTT63NySAcNjgPPcRgcHAQACILAhBFFEUajMaOSKIoQRRG1tbUwmUxZeRcuXIDT6WRcLpcLg4OD0gkwJawkriRwIBDIapjZbGaWazabs/Jz1ZmdFo1GcaanBx2dh2C+ZEHFwxsAAANeLwa8XhQXF4NbpJyTZ5FSicaGBtyxeDFLG/B6WXyZdlne9gDMgqUPlk9oK1euZAXq6+sBSPNMKBSCx+OBVqvFtm3bmCXr9XqEQiEcO3YsY48MgMWnolPSe8ClPYHS0lKIoohwOJzRMLmDZscBaQ8qiiJ0Oh1L0+l0WTw/efIptO/dh1V3rkTN5i346HIYVdXV6Og8hJqtWwviGR8fR1tLKx5/bDPa9+5D+959aGlqAgDs2r07b3syBAaHjOGaPp/IPWM2m9lkHgqFYDabWZ58+BAEgeXJSF+8JKPNPDZvfExadOSOLARyWaFKYGlyPJ2no/MQLNu348o//o6/hUJw2O3Y09KMqupqWPfvQ9ma1fPyWLZvh2X7dgCAs7sbzu5uXP/0OjZUPIItNY/nbY+M7PHxX8a69eugK9XB7XbDYrFkWetsyKenEl1Jhh9g1ZoylOhKMniKi4uxp6UZX1q8GCPDw/hZXd0N8expacb3H3oIly+HAUijTldaOiePDMmCKdOLlT6fyNbscrkwOTmJQCCA5cuXw2q1sjz5mJyeJyN9yEpnM3l7PIPmtmaoVCq4XC6YTCZWh9K8bOFwGCaTCV1dXVCpVNhRuyPrY3b/sjEnz85dDXjjrTc/E8/qNatRVV2Nqupq6EpLC+IBUs4e38ggioqKsP7e+zAVnYLZbGaW5Ha7sxYyQJoyKisr8+bJ9evr69HV1YUlqiU4/5c+TE9PYzo2jVg8hlgsLjmDEnFE/jmJA9YDbC+p1+uh1+uhVqshiiLr9PmcNNei19BxwMacNLeShzl7BoYHUFRUBGuLFe5jbqjVakQiEVZQFEU4HA7mzDEYDGhtbWUd4HA4WNn0PABYvnw5wuEwHvjuAzhs78T16WnEZgks+42TiSR8Az4cO3rr3Yw3g4cJ7B3qx6JFRTh/7jxqn5X2v3a7HXVpc9aNwOVysVPY/gP78fCGhzAdm8Z0LIZ4LIZYfJbAORzw/8vYWLlJmoPlKx2DsRwajQYAYLVas7ZOC8Hk5CRbXTUaTcoRn7rFSCaRTM3FlLpyul3BA0CSkkgkpHu0fe17AUgCmUymDB9voZicnITRaGR1G3/emHKwJ2ZETrsyYovsrMX2dgEBoKbWJvKNDFLgop+e+OETGR41v9+/IE9XuidNMAkUuOgn38gg7W3fy9L/j8LMj7rnamnI76PADTjcI5EItbW1ZTjc16xdQxc+CNBQwEdNrU23+kNvSWDX9jKaW5tQaRKgVCpx2HYYr7/2Ostb6JWRdV8b4vE4BgYG8cxTz2A+pE8P8smSiDJOmbN/5+PJV0d+R6GOpnxtWhDH7NDc2iRZ8kU/dbteJY1GU3CPaTQachxxUOCin4YCPnr51y8XXJeI5oynp83HM1/9QrhylVkoR5YFy6h7rhY1W2vYVY/o6cWJ4yfmvLZ/VHgUBkM5u9A8fvwE9lv3F9DHEnJZS3reQqyO47i8z4VgtrXOXoTn48srMACsuqsMza0tKF6qSbuNSHc3ImPfKv/xZGJ8HC902nGu99yCP+azTA35eABkCbxQsXN1UiEccwos4/7y+7GhYgPuWn0XvqJSpf46Jb9ZetHVaBTDQ8M4ffL0goVN/wjWsJtgwbl+L2T+nG9NuGkCf4EbB09EX77VjbhdQUTcvwFtwhQyXNo3TwAAAABJRU5ErkJggg==";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g,k,b,c,d,j,f,r,m;a.Color=function(a,d){this.b=this.g=this.r=0;this.a=1;this.evaluator=d;if(a){if(babel[a]&&("net"===babel[a]&&(a="rojo"),a=babel[a],this.r=parseInt("0x"+a.substring(1,3),16),this.g=parseInt("0x"+a.substring(3,5),16),this.b=parseInt("0x"+a.substring(5,7),16),this.colorStr=a,this.getColor=this.getColorString),6===a.length&&(this.r=parseInt("0x"+a.substring(0,2),16),this.g=parseInt("0x"+
a.substring(2,4),16),this.b=parseInt("0x"+a.substring(4,6),16),this.colorStr="#"+a,this.getColor=this.getColorString),8===a.length&&(this.r=parseInt("0x"+a.substring(2,4),16),this.g=parseInt("0x"+a.substring(4,6),16),this.b=parseInt("0x"+a.substring(6,8),16),this.a=1-parseInt("0x"+a.substring(0,2),16)/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString),"("===a[0]){k=[];b=this.splitComa(a.substring(1,a.length-1));for(var f=0,j=b.length;f<j;f++)c=
parseInt(b[f],16),b[f]!=c.toString(16)&&b[f]!=="0"+c.toString(16)?("["===b[f].charAt(0)&&"]"===b[f].charAt(b[f].length-1)&&(b[f]=b[f].substring(1,b[f].length-1)),k.push(this.evaluator.parser.parse(b[f]))):k.push(this.evaluator.parser.parse((c/255).toString()));this.rExpr=k[0];this.gExpr=k[1];this.bExpr=k[2];this.aExpr=k[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){d=
[];for(var b=r=f=j=0,c=a.length;b<c;b++)m=a.charAt(b),"("===m?j++:")"===m?j--:"["===m?f++:"]"===m?f--:","===m&&(0===j&&0===f)&&(d.push(a.substring(r,b)),r=b+1);d.push(a.substring(r));return d};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){g=this.evaluator;this.r=e(255*g.evalExpression(this.rExpr));this.g=e(255*g.evalExpression(this.gExpr));this.b=e(255*g.evalExpression(this.bExpr));this.a=1-g.evalExpression(this.aExpr);return"rgba("+
this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"white":"black"};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=document.head,g=document.createElement("meta");g.setAttribute("http-equiv","X-UA-Compatible");g.setAttribute("content","chrome=1");e.appendChild(g);g=document.createElement("meta");g.setAttribute("name","viewport");g.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
e.appendChild(g);g=document.createElement("meta");g.setAttribute("name","apple-mobile-web-app-capable");g.setAttribute("content","yes");e.appendChild(g);g=document.createElement("meta");g.setAttribute("name","apple-mobile-web-app-status-bar-style");g.setAttribute("content","black-translucent");e.appendChild(g);(e=document.getElementById("StyleDescartesApps2"))&&e.parentNode.removeChild(e);e=document.createElement("style");e.type="text/css";e.id="StyleDescartesApps2";e.setAttribute("rel","stylesheet");
document.head.appendChild(e);e.innerHTML="body{ text-rendering:geometricPrecision; }\ncanvas{ image-rendering:optimizeSpeed; image-rendering:-moz-crisp-edges; image-rendering:-webkit-optimize-contrast; image-rendering:optimize-contrast; -ms-interpolation-mode:nearest-neighbor; }\ndiv.DescartesCatcher{ background-color:rgba(255, 255, 255, 0); cursor:pointer; position:absolute; }\ndiv.DescartesAppContainer{ border:0px solid black; position:relative; overflow:hidden; top:0px; left:0px; }\ndiv.DescartesLoader{ background-color :#efefef; position:absolute; overflow:hidden; -moz-box-shadow:0px 0px 0px #888; -webkit-box-shadow:0px 0px 100px #888; box-shadow:0px 0px 100px #888; background-image:linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-o-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-moz-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-webkit-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-ms-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); top:0px; left:0px; }\ndiv.DescartesLoaderImage{ background-repeat:no-repeat; background-position:center; position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesLoaderBar{ position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesSpace2DCanvas, canvas.DescartesSpace3DCanvas, div.blocker{ position:absolute; overflow:hidden; left:0px; top:0px; }\ndiv.DescartesSpace2DContainer, div.DescartesSpace3DContainer{ position:absolute; overflow:hidden; line-height:0px; }\ncanvas.DescartesButton{ position:absolute; cursor:pointer; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding:0px; border:solid #666666 1px; position:absolute; top:0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; font-weight:normal; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:#e0e4e8; position:absolute; left:0px; top:0px; }\ndiv.DescartesGraphicControl{ border-style:none; position:absolute; }\ndiv.DescartesTextAreaContainer{ position:absolute; overflow:hidden; background:#c0d0d8; }\nselect.DescartesMenuSelect{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding-top:0%; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:white; position:absolute; left:0px; top:0px; }\ndiv.DescartesScrollbarContainer{ background:#eeeeee; overflow:hidden; position:absolute; }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sin,g=Math.floor,k=Math.random,b=Math.round,c=Math.abs,d=String.fromCharCode,j,f,r,m,l,q,p,t,n,u;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){j=[];for(var b=0;256>b;b++)j[b]=d(this.alfanum(g(c(7.5*(e(1*b-a)+e(1.4*b+a)+e(0.6*b-a)+e(2.2*b+a))))));return j.join("")};a.Krypto.prototype.encode=function(a){f=g(31*k());this.key=this.getKey(f);m=d(this.alfanum(f));return m+this.encripta(a)};
a.Krypto.prototype.decode=function(a){f=this.numalfa(a.charCodeAt(0));this.key=this.getKey(f);return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;q=Array(3*a.length);for(var d=0,f=a.length;d<f;d++)n=256*g(a[d]+128)+b(255*k())+65536*b(255*k()),u=g((n<<this.shift(d))/256),q[3*d]=this.alfanum(u%32),q[3*d+1]=this.alfanum(u/32%
32),q[3*d+2]=this.alfanum(u/1024%32);return q};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;p=Array(a.length/3);for(var b=0,d=p.length;b<d;b++)u=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),n=g(256*u>>this.shift(b)),t=g(n/256)%256-128,0>t&&(t+=256),p[b]=t;return p};a.Krypto.prototype.alfanum=function(a){a=g(a);return 10>
a?48+a:87+a};a.Krypto.prototype.numalfa=function(a){return 58>a?a-48:a-87};a.Krypto.prototype.stringToBytes=function(a){m=Array(a.length);for(var b=0,d=a.length;b<d;b++)m[b]=a.charCodeAt(b);return m};a.Krypto.prototype.bytesToString=function(a){for(var b=0,f=a.length;b<f;b++)a[b]=d(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){r=this.key.charCodeAt(a%this.key.length);m=this.numalfa(r);l=g(m/2%8);0==l&&(l=4);return l};a.Krypto.prototype.parseByte=function(a){a=parseInt(a);a=0>a?0:a;
return 255<a?255:a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animation=function(e,g){this.parent=e;var k=e.evaluator,b=k.parser,c=new a.Auxiliary(e);this.delay=g.delay?b.parse(g.delay):b.parse("60");this.loop=g.loop?g.loop:!1;this.auto=void 0==g.auto?!0:g.auto;this.controls=g.controls;this.init=c.splitInstructions(b,g.init);this.doExpr=c.splitInstructions(b,g.doExpr);g.whileExpr&&(this.whileExpr=b.parse(g.whileExpr));var d=this,j,f,r=d.doExpr.length;this.animationExec=
function(){for(f=0;f<r;f++)k.evalExpression(d.doExpr[f]);d.parent.update();d.playing&&(0<k.evalExpression(d.whileExpr)||d.loop)?(j=k.evalExpression(d.delay),d.timer=setTimeout(d.animationExec,10>j?10:j)):(d.stop(),d.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,g=this.init.length;a<g;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Message=function(e,g){a.Action.call(this,e,g);this.parameter=(g||"").replace(/\\n/g,
"\n").replace(/&squot;/g,"'")};a.extend(a.Message,a.Action);a.Message.prototype.execute=function(){alert(this.parameter)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Calculate=function(e,g){a.Action.call(this,e,g);var k=this.evaluator,b=k.parser;g=(g||"").replace(/&squot;/g,"'");g=g.replace(/;/g,"\\n");g=g.split("\\n")||[""];for(var c=[],d,j=0,f=g.length;j<f;j++)(d=b.parse(g[j],!0))&&c.push(d);f=c.length;this.execute=function(){for(j=0;j<f;j++)k.evalExpression(c[j])}};
a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,g){a.Action.call(this,e,g);this.parameter=g;this.target="_blank";var k=this.parameter.indexOf("target");-1!=k&&(this.target=this.parameter.substring(k),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,k-1));"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),
this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target)})};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(e,g){a.Action.call(this,e,g);this.parameter=g;this.target=
"_blank";var k=this.parameter.indexOf("target");-1!=k&&(this.target=this.parameter.substring(k),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,k-1));"_blank"!==this.target&&"_parent"!==this.target&&"_self"!==this.target&&"_top"!==this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,
"'"),this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){this.window=window.open(this.parameter,this.target,"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
this.window.onload=function(){var a=this.document,c=a.getElementsByTagName("applet");c&&0<c.length&&(this.innerWidth=c[0].width,this.height=c[0].height,a.body.style.margin="0px",a.body.style.padding="0px",c[0].parentNode.style.margin="0px",c[0].parentNode.style.padding="0px")}})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.About=function(e,g){a.Action.call(this,e,g);g||(this.urlAbout=
window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+g)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Config=function(e,g){a.Action.call(this,e,g)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'>"+this.parent.applet.outerHTML+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(e,g){a.Action.call(this,e,g)};
a.extend(a.Init,a.Action);a.Init.prototype.execute=function(){this.parent.init()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Clear=function(e,g){a.Action.call(this,e,g)};a.extend(a.Clear,a.Action);a.Clear.prototype.execute=function(){this.parent.clear()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animate=function(e,g){a.Action.call(this,e,g)};a.extend(a.Animate,a.Action);a.Animate.prototype.execute=function(){this.parent.play()};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.InitAnimation=function(e,g){a.Action.call(this,e,g)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;a.PlayAudio=function(g,k){a.Action.call(this,g,k);this.filenameExpr=k&&k.match(e)?this.evaluator.parser.parse("'"+k.match(e)+"'"):this.evaluator.parser.parse(k)};
a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.evalExpression(this.filenameExpr));a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,b){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c])};a.Auxiliary.prototype.firstRun=
function(){};a.Auxiliary.prototype.update=function(){};var e,g;a.Auxiliary.prototype.splitInstructions=function(a,b){g=[];b=b?b.split(";"):[""];for(var c=0,d=b.length;c<d;c++)(e=a.parse(b[c],!0))&&g.push(e);return g};a.Auxiliary.prototype.getPrivateVariables=function(a,b){g=[];b=b?b.split(/;|,/):[""];for(var c=0,d=b.length;c<d;c++)(e=a.parse(b[c],!0))&&g.push(e);c=0;for(d=g.length;c<d;c++)g[c]="asign"===g[c].type?g[c].childs[0].value:"identifier"===g[c].type?g[c].value:"";return g};a.Auxiliary.prototype.parseExpressions=
function(a){this.init=this.splitInstructions(a,this.init);this.privateVars=this.getPrivateVariables(a,this.local);this.doExpr=this.splitInstructions(a,this.doExpr);this.whileExpr=a.parse(this.whileExpr)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(e,g){a.Auxiliary.call(this,e,g);var k=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=k.parse(this.expresionString))&&k.setVariable(this.id,this.expresion);this.editable&&(this.registerTextField(),
this.parent.editableRegionVisible=!0)};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=function(){var a=document.createElement("div"),g=document.createElement("label");g.appendChild(document.createTextNode("___"+this.id+"=___"));var k=document.createElement("input");k.value=this.expresionString;k.disabled=!this.editable;a.appendChild(g);a.appendChild(k);var b=this,c=b.evaluator.parser;k.onkeydown=function(a){13==a.keyCode&&(b.expresion=c.parse(this.value),c.setVariable(b.id,
b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(e,g){a.Auxiliary.call(this,e,g);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e,g,k;a.Vector=function(b,c){e=b.evaluator;g=e.parser;this.size=g.parse("3");a.Auxiliary.call(this,b,c);this.expresion=this.expresion.split(";");this.parseFile=g.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var b=this.expresion;e=this.evaluator;g=e.parser;this.oldFile=this.file;if(k=e.evalExpression(this.parseFile))this.file=k;var c;if(this.file){c=(vectorElement=document.getElementById(this.file))&&"descartes/vectorFile"==vectorElement.type?
vectorElement.text:a.openExternalFile(this.file);if(null!=c){c=c.replace(/\r/g,"").split("\n");for(var d=[],j=0,f=c.length;j<f;j++)""!=c[j]&&d.push(c[j]);c=d}null==c||1==c.length&&""==c[0]?this.size=0:(b=c,this.size=null);null===this.size&&(this.size=g.parse(b.length+""))}c=[];j=0;for(f=b.length;j<f;j++)(d=g.parse(b[j],!0))&&"asign"!=d.type&&(d=g.parse(this.id+"["+j+"]="+b[j],!0)),c.push(d);b=[];j=0;for(f=e.evalExpression(this.size);j<f;j++)b.push(0);e.vectors[this.id]=b;e.setVariable(this.id+".long",
e.evalExpression(this.size));j=0;for(f=c.length;j<f;j++)e.evalExpression(c[j])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,g){var k=e.evaluator,b=k.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,e,g);this.expresion=this.splitInstructions(b,this.expresion);var b=k.evalExpression(this.rows),c=k.evalExpression(this.columns),d=[];d.type="matrix";for(var j,f=0;f<c;f++){j=[];for(var r=0,m=b;r<m;r++)j.push(0);d[f]=j}k.matrices[this.id]=
d;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,g=a.evalExpression(this.rows),k=a.evalExpression(this.columns);a.setVariable(this.id+".filas",g);a.setVariable(this.id+".columnas",k);var b=a.matrices[this.id];b.rows=g;b.cols=k;g=0;for(k=this.expresion.length;g<k;g++)a.evalExpression(this.expresion[g])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(e,g){a.Auxiliary.call(this,e,g);var k=this.evaluator,
b=k.parser,c=this.id.indexOf("(");this.name=this.id.substring(0,c);this.params=this.id.substring(c+1,this.id.length-1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(b);this.expresion=b.parse(this.expresion);var d=this;this.functionExec=function(){this.iterations=0;if(d.numberOfParams<=arguments.length){for(var b=[],f=
0,c=d.privateVars.length;f<c;f++)b.push(k.getVariable(d.privateVars[f])),k.setVariable(d.privateVars[f],0);for(var e=[],f=0,c=d.params.length;f<c;f++)e[f]=k.getVariable(d.params[f]),k.setVariable(d.params[f],arguments[f]);f=0;for(c=d.init.length;f<c;f++)k.evalExpression(d.init[f]);do{f=0;for(c=d.doExpr.length;f<c;f++)k.evalExpression(d.doExpr[f]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n",this.id),0}while(0<k.evalExpression(d.whileExpr));
var l=k.evalExpression(d.expresion);a.rangeOK=k.evalExpression(d.domain);f=0;for(c=d.params.length;f<c;f++)k.setVariable(d.params[f],e[f]);f=0;for(c=d.privateVars.length;f<c;f++)k.setVariable(d.privateVars[f],b[f]);return l}return 0};k.setFunction(this.name,this.functionExec)};a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(e,g){a.Auxiliary.call(this,e,g);var k=this.evaluator;this.parseExpressions(k.parser);this.algorithmExec=
function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)k.evalExpression(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)k.evalExpression(this.doExpr[a]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en el algoritmo",this.id),0}while(0<k.evalExpression(this.whileExpr))}};a.extend(a.Algorithm,a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"===this.evaluate&&(this.update=function(){})};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Event=function(e,g){a.Auxiliary.call(this,e,g);var k=this.evaluator;this.condition=k.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<k.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<k.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<k.evalExpression(this.condition)&&this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,
k,b,c;a.Graphic=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=f.parse("1");this.abs_coord=!1;this.color=new a.Color("blue");2!==this.parent.version&&(this.color=new a.Color("20303a"),this.parent.arquimedes&&(this.color=new a.Color("black")));this.trace="";this.expresion=f.parse("(0,0)");this.family="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.editable=!1;this.font=5<=this.parent.version?
"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=f.parse("2");for(var e in c)c.hasOwnProperty(e)&&(this[e]=c[e]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10};a.Graphic.prototype.getSpace=
function(){for(var a=this.parent.spaces,b,c=0,e=a.length;c<e;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic.prototype.getFamilyValues=function(){e=this.evaluator;g=e.evalExpression(this.family_interval);this.familyInf=g[0][0];this.familySup=g[0][1];this.fSteps=Math.round(e.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,c){e=this.evaluator;this.getFamilyValues();k=e.getVariable(this.family);
if(0<=this.fSteps)for(var g=0,m=this.fSteps;g<=m;g++)e.setVariable(this.family,this.familyInf+g*this.family_sep),0<e.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,c));e.setVariable("_Text_H_",0);e.setVariable(this.family,k)};a.Graphic.prototype.draw=function(a,b){""!=this.family?this.drawFamilyAux(this.ctx,a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.ctx,a,b))};a.Graphic.prototype.drawTrace=function(a,b){""!=this.family?this.drawFamilyAux(this.traceCtx,
a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,b))};a.Graphic.prototype.drawText=function(a,j,f,k,g,l,q,p,t,n,u){if("rtfNode"===j.type)a.fillStyle=g.getColor(),a.strokeStyle=g.getColor(),a.textBaseline="alphabetic",j.draw(a,f,k,t,n,q,u);else{"simpleText"===j.type&&(j=j.toString(t,n).split("\\n"));f+=l.match("Arial")?-2:l.match("Times")?-2:0;e=this.evaluator;a.fillStyle=g.getColor();a.font=l;a.textAlign=q;a.textBaseline=p;this.border&&(a.strokeStyle=
this.border.getColor(),a.lineWidth=3);c=1.2*this.fontSize||0;g=0;for(l=j.length;g<l;g++)b=j[g],this.border&&(a.lineJoin="round",a.strokeText(b,f,k+c*g)),a.fillText(b,f,k+c*g)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,b){this.text=b=b.replace("&#x2013","\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var c="'",d=0,j=0,f=-1,e,g;d<b.length;)e=
b.charAt(d),g=b.charAt(d-1),"["===e&&"\\"===g?(this.textElements.push(b.substring(j,d-1)+"["),this.textElementsMacros.push("'"+b.substring(j,d-1)+"['"),j=d+1):"]"===e&&"\\"===g?(this.textElements.push(b.substring(j,d-1)+"]"),this.textElementsMacros.push("'"+b.substring(j,d-1)+"]'"),j=d+1):"["===e&&-1===f?(this.textElements.push(b.substring(j,d)),this.textElementsMacros.push("'"+b.substring(j,d)+"'"),j=d,f++):"["===e?f++:"]"===e&&0===f?(this.textElements.push(this.evaluator.parser.parse(b.substring(j,
d+1))),this.textElementsMacros.push("["+b.substring(j,d+1)+"]"),j=d+1,f--):("]"==b.charAt(d)&&(f=0>f?f:f-1),c+=b.charAt(d)),d++;this.textElements.push(b.substring(j,d));this.textElementsMacros.push("'"+b.substring(j,d)+"'")};var e,g;a.SimpleText.prototype.toString=function(a,b){e="";for(var c=0,d=this.textElements.length;c<d;c++)"string"===typeof this.textElements[c]?e+=this.textElements[c]:(g=this.evaluator.evalExpression(this.textElements[c])[0][0],""!==g&&("string"===typeof g?e+=g:(g=parseFloat(g),
g=b?g.toFixed(a):parseFloat(g.toFixed(a)),e+=g.toString().replace(".",this.parent.decimal_symbol))));return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s,v,y,B,x,D,C,A,z,G,F;a.Equation=function(b,d){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,d);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();
p=new a.R2;t=new a.R2;n=new a.R2;s=new a.R2;u=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],d=this.expresion.childs[1];"identifier"==b.type&&"y"==b.value&&!d.contains("y")?(this.funExpr=d,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==d.type&&"y"==d.value&&!b.contains("y")?(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==b.type&&"x"==b.value&&!d.contains("x")?
(this.funExpr=d,this.of_y=!0,this.drawAux=this.drawAuxFun):"identifier"==d.type&&("x"==d.value&&!b.contains("x"))&&(this.of_y=!0,this.funExpr=d,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=function(){this.auxCanvas=document.createElement("canvas");this.oldWwidth=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(this.oldWwidth/2)||1;this.auxCanvas.setAttribute("width",this.oldWwidth);this.auxCanvas.setAttribute("height",
this.oldWwidth);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.fillRect(0,0,this.oldWwidth,this.oldWwidth)};var H;a.Equation.prototype.update=function(){H=parseInt(this.evaluator.evalExpression(this.width));H!==this.oldWwidth&&this.generateStroke()};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))};a.Equation.prototype.drawFamilyAux=
function(a,b,d){k=this.evaluator;this.getFamilyValues();tempParam=k.getVariable(this.family);if(0<=this.fSteps)for(var c=0,f=this.fSteps;c<=f;c++)k.setVariable(this.family,this.familyInf+c*this.family_sep),this.update(),this.drawAux(a,b,d);k.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(H,w,I){H.lineWidth=1;k=this.evaluator;b=k.parser;c=this.space;d=k.evalExpression(this.width);
H.fillStyle=I.getColor();H.translate(-parseInt(d/2),-parseInt(d/2));j=b.getVariable("x");f=b.getVariable("y");r=c.w;m=c.h;l=parseInt(r/8);3>l&&(l=3);q=parseInt(m/8);3>q&&(q=3);g=[];p.set(0,0);t.set(0,0);n.set(0,0);for(F=parseInt(q/2);F<m;F+=q)for(G=parseInt(l/2);G<r;G+=l)if(this.abs_coord?(s.set(G,F),h=this.newt.findZero(s),k.setVariable("x",h.x),k.setVariable("y",h.y),u.set(h.x,h.y)):(s.set(c.getRelativeX(G),c.getRelativeY(F)),h=this.newt.findZero(s),k.setVariable("x",h.x),k.setVariable("y",h.y),
u.set(c.getAbsoluteX(h.x),c.getAbsoluteY(h.y))),v=u.ix(),y=u.iy(),!(0>v||v>=r||0>y||y>=m||g[v+y*c.w]))if(g[v+y*c.w]=!0,a.rangeOK&&k.evalExpression(this.drawif)&&H.drawImage(this.auxCanvas,v,y),p.x=h.x,p.y=h.y,t.x=h.x,t.y=h.y,B=this.newt.getUnitNormal(),!(0==B.x&&0==B.y)){B.rotL90();n.x=B.x;n.y=B.y;D=x=0;for(C=!1;2>D;){C&&(n.x=-B.x,n.y=-B.y,h.x=p.x,h.y=p.y,t.x=h.x,t.y=h.y,this.abs_coord?u.set(h.x,h.y):u.set(c.getAbsoluteX(h.x),c.getAbsoluteY(h.y)),v=u.ix(),y=u.iy(),C=!1,x=0);this.abs_coord?(h.x+=n.x,
h.y+=n.y):(h.x+=n.x/c.scale,h.y+=n.y/c.scale);h=this.newt.findZero(h);k.setVariable("x",h.x);k.setVariable("y",h.y);n.x=h.x-t.x;n.y=h.y-t.y;n.normalize();if(0==n.x&&0==n.y)break;t.x=h.x;t.y=h.y;this.abs_coord?u.set(h.x,h.y):u.set(c.getAbsoluteX(h.x),c.getAbsoluteY(h.y));A=e(u.ix());z=e(u.iy());if(A!=v||z!=y)if(v=A,y=z,0<=v&&v<r&&0<=y&&y<m)if(x=0,g[v+y*c.w])break;else g[v+y*c.w]=!0,a.rangeOK&&k.evalExpression(this.drawif)&&H.drawImage(this.auxCanvas,v,y);else C=!0,D++;else 4<++x&&(C=!0,D++)}}H.setTransform(1,
0,0,1,0,0)};a.Equation.prototype.X=function(a,b,d){d||(b=this.space.w/2+this.space.Ox+this.space.scale*b);b<-a&&(b=-a);b>this.space.w+a&&(b=this.space.w+a);return b};a.Equation.prototype.Y=function(a,b,d){d||(b=this.space.h/2+this.space.Oy-this.space.scale*b);b<-a&&(b=-a);b>this.space.h+a&&(b=this.space.h+a);return b};a.Equation.prototype.XX=function(a,b,d){return Math.round(this.X(a,b,d))};a.Equation.prototype.YY=function(a,b,d){return Math.round(this.Y(a,b,d))};a.Equation.prototype.extrapolate=
function(b,d,c,f,h,j){for(var e=this.evaluator.getVariable(d),k=j/2,n=0;1E-12<Math.abs(k);){var l=this.evaluator.getVariable(d),g=this.evaluator.getVariable(d)+k;this.evaluator.setVariable(d,g);var m=!0,p=h;h=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(c,h);if(0<this.evaluator.evalExpression(b)){var r=new a.R2(Math.min(p,h),Math.max(p,h)),q=0,q=0<j?this.Singularity(Math.abs(k),d,f,l,p,g,h,r):this.Singularity(Math.abs(k),d,f,g,h,l,p,r);0<q&&(m=!1)}else m=!1;m?n+=k:this.evaluator.setVariable(d,
l);k/=2}this.evaluator.setVariable(d,e);return new a.R2(n/Math.abs(j),h)};a.Equation.prototype.extrapolateOnSingularity=function(b,d,c,f,h,j){f=this.evaluator.getVariable(d);for(var e=j/2,k=0,n=h;1E-12<Math.abs(e);){this.evaluator.setVariable(this.evaluator.getVariable(d)+e);var l=!0;0<this.evaluator.evalExpression(b)?(n=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(c,n),0>=this.evaluator.evalExpression(b)&&(l=!1)):l=!1;l?k+=e:this.evaluator.setVariable(this.evaluator.getVariable(d)-
e);e/=2}if(0==k){e=j/2;k=j;for(n=h;1E-12<Math.abs(e);)this.evaluator.setVariable(this.evaluator.getVariable(d)-e),l=!0,0<this.evaluator.evalExpression(b)?n=this.evaluator.evalExpression(this.funExpr):l=!1,l?k+=-e:this.evaluator.setVariable(this.evaluator.getVariable(d)+e),e/=2}this.evaluator.setVariable(f);return new a.R2(k/Math.abs(j),n)};a.Equation.prototype.Singularity=function(a,b,d,c,f,h,e,j){if(c>=h)return 2;var k=this.evaluator.getVariable(b),n=0;if(1E-12>Math.abs(h-c)||1E-8>Math.abs(h-c)&&
Math.abs(e-f)>Math.abs(a))return this.evaluator.setVariable(b,k),1;var l=(c+h)/2;this.evaluator.setVariable(b,l);var g=this.evaluator.evalExpression(this.funExpr);if(Math.abs(e-f)>a){this.evaluator.setVariable(b,c-1E-6);var m=this.evaluator.evalExpression(this.funExpr),m=(f-m)/1E-6;this.evaluator.setVariable(b,h+1E-6);var p=(this.evaluator.evalExpression(this.funExpr)-e)/1E-6,r=(e-f)/(h-c);if(10>Math.abs(p)||10>Math.abs(m))if((0<=p&&0<=m||0>=p&&0>=m)&&8*Math.abs(p)<Math.abs(r))return this.evaluator.setVariable(b,
k),2}j.x<=g&&g<=j.y||(this.evaluator.setVariable(b,l),j.x=Math.min(f,g),j.y=Math.max(f,g),c=this.Singularity(a/2,b,d,c,f,l,g,j),this.evaluator.setVariable(b,h),j.x=Math.min(e,g),j.y=Math.max(e,g),a=this.Singularity(a/2,b,d,l,g,h,e,j),n=Math.max(c,a));this.evaluator.setVariable(b,k);return n};a.Equation.prototype.drawAuxFun=function(b){j=this.evaluator.parser.getVariable("x");f=this.evaluator.parser.getVariable("y");var d="x",c="y";this.of_y&&(d="y",c="x");var h=this.drawif,e=this.evaluator.evalExpression(this.width),
k=!1,l=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),l=this.of_y?l.ix():l.iy(),n=0,g=0,m=0,p=1/this.space.scale,r=p*(this.of_y?-this.space.h+(this.space.h/2+this.space.Oy):-(this.space.w/2+this.space.Ox)),n=0;this.abs_coord&&(r=this.space.h,p=-1);for(var q=this.of_y?this.space.h:this.space.w;g<q;){var t=!0,v=0;this.evaluator.setVariable(d,r);var u=this.evaluator.evalExpression(this.funExpr);if(isNaN(u))t=!1;else{this.evaluator.setVariable(c,u);if(0<this.evaluator.evalExpression(this.drawif)&&
a.rangeOK){if(k){var v=Math.min(n,u),s=Math.max(n,u),s=new a.R2(v,s),v=this.Singularity(p,d,0,r-p,n,r,u,s);0===v?(n<=u?(n=s.x,u=s.y):(u=s.x,n=s.y),v=this.of_y?this.XX(e,n,this.abs_coord):this.YY(e,n,this.abs_coord),n=this.abs_coord?Math.round(u):this.of_y?this.XX(e,u,this.abs_coord):this.YY(e,u,this.abs_coord),this.fillM&&n>l&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(l+1,this.space.h-g+0.5),b.lineTo(n,this.space.h-g+0.5)):(b.moveTo(g+0.5,l+1),b.lineTo(g+
0.5,n)),b.stroke()),this.fillP&&n<l&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(l-1,this.space.h-g+0.5),b.lineTo(n,this.space.h-g+0.5)):(b.moveTo(g+0.5,l-1),b.lineTo(g+0.5,n)),b.stroke()),b.lineWidth=e,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(v+0.5,this.space.h-m),b.lineTo(n+0.5,this.space.h-g)):(b.moveTo(m+0.5,v),b.lineTo(g+0.5,n)),b.stroke()):(1===v&&(this.evaluator.setVariable(d,r-p),m=this.extrapolate(h,d,c,0,n,p),this.YY(e,
m.y,this.abs_coord),this.evaluator.setVariable(d,r),m=this.extrapolate(h,d,c,0,u,-p),this.YY(e,m.y,this.abs_coord)),this.YY(e,u,this.abs_coord))}else m=this.extrapolateOnSingularity(h,d,c,0,u,-p),this.YY(e,m.y,this.abs_coord),this.YY(e,u,this.abs_coord);n=u}else t=!1;k&&!t&&(this.evaluator.setVariable(d,r-p),this.evaluator.setVariable(c,n),m=this.extrapolate(h,d,c,0,n,p),this.YY(e,m.y,this.abs_coord),this.evaluator.setVariable(d,r))}k=t;r+=p;m=g++}this.evaluator.parser.setVariable("x",j);this.evaluator.parser.setVariable("y",
f)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Curve=function(b,d){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");
this.parameter_steps=b.evaluator.parser.parse("8");this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,d);(this.visible=2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var g,k,b,c,d,j,f,r,m,l,q;a.Curve.prototype.update=function(){g=this.evaluator;k=g.evalExpression(this.parameter_interval);this.paraInf=k[0][0];this.paraSup=k[0][1];this.pSteps=g.evalExpression(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-
this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Curve.prototype.drawAux=function(k,t,n){g=this.evaluator;b=this.space;c=e(g.evalExpression(this.width));k.lineWidth=0<c?c:1E-6;k.lineCap="round";k.lineJoin="round";k.strokeStyle=n.getColor();d=g.getVariable(this.parameter);k.beginPath();g.setVariable(this.parameter,this.paraInf);j=g.evalExpression(this.expresion);
this.exprX=this.abs_coord?e(j[0][0]):e(b.getAbsoluteX(j[0][0]));this.exprY=this.abs_coord?e(j[0][1]):e(b.getAbsoluteY(j[0][1]));this.rotateExp&&(f=a.degToRad(g.evalExpression(this.rotateExp)),r=Math.cos(f),m=Math.sin(f),l=this.exprX*r-this.exprY*m,q=this.exprX*m+this.exprY*r,this.exprX=l,this.exprY=q);k.moveTo(this.exprX+0.5,this.exprY+0.5);for(n=1;n<=this.pSteps;n++)g.setVariable(this.parameter,this.paraInf+n*this.paraSep),j=g.evalExpression(this.expresion),this.exprX=this.abs_coord?e(j[0][0]):e(b.getAbsoluteX(j[0][0])),
this.exprY=this.abs_coord?e(j[0][1]):e(b.getAbsoluteY(j[0][1])),this.rotateExp&&(l=this.exprX*r-this.exprY*m,q=this.exprX*m+this.exprY*r,this.exprX=l,this.exprY=q),k.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(k.fillStyle=t.getColor(),k.fill());k.stroke();g.setVariable(this.parameter,d)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),
b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,g=Math.round,k,b,c,d,j,f,r,m,l,q,p,t,n;a.Sequence=function(b,d){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,d)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){k=this.evaluator;c=k.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&
(d=a.degToRad(k.evalExpression(this.rotateExp)),j=Math.cos(d),f=Math.sin(d),r=this.exprX*j-this.exprY*f,m=this.exprX*f+this.exprY*j,this.exprX=r,this.exprY=m);p=k.evalExpression(this.range);this.rangeInf=p[0][0];this.rangeMax=p[0][1]};a.Sequence.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Sequence.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Sequence.prototype.drawAux=function(a,d){k=this.evaluator;b=this.space;t=Math.ceil(k.evalExpression(this.size)-
0.4);a.fillStyle=d.getColor();a.beginPath();this.rangeInf>this.rangeMax&&(n=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=n);for(var f=k.getVariable("n"),j=this.rangeInf,m=this.rangeMax;j<=m;j++)k.setVariable("n",j),c=k.evalExpression(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],l=this.abs_coord?g(this.exprX):g(b.getAbsoluteX(this.exprX)),q=this.abs_coord?g(this.exprY):g(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(l,q,t,0,e,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,
a,this.text,l+t,q-t,this.color,this.font,"start","alphabetic",k.evalExpression(this.decimals),this.fixed,!0);k.setVariable("n",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,g=Math.round,k,b,c,d,j,f,r,m,l,q,p,t;a.Point=function(b,d){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,d)};a.extend(a.Point,a.Graphic);a.Point.prototype.update=function(){k=this.evaluator;c=k.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&
(d=a.degToRad(k.evalExpression(this.rotateExp)),j=Math.cos(d),f=Math.sin(d),r=this.exprX*j-this.exprY*f,m=this.exprX*f+this.exprY*j,this.exprX=r,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,d){k=this.evaluator;b=this.space;p=g(k.evalExpression(this.size));t=p+1;a.fillStyle=d.getColor();l=this.abs_coord?g(this.exprX):
g(b.getAbsoluteX(this.exprX));q=this.abs_coord?g(this.exprY):g(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(l,q,p,0,e,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,l+t+1,q-t,this.color,this.font,"start","alphabetic",k.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,g=2*Math.PI,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s,v,y;a.Segment=function(b,d){this.width=b.evaluator.parser.parse("1");this.size=
b.evaluator.parser.parse("2");a.Graphic.call(this,b,d)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){k=this.evaluator;c=k.evalExpression(this.expresion);this.endPoints=[];for(var b=0,h=c.length;b<h;b++)this.endPoints[b]={x:c[b][0],y:c[b][1]};if(this.rotateExp){d=a.degToRad(k.evalExpression(this.rotateExp));j=Math.cos(d);f=Math.sin(d);b=0;for(h=this.endPoints.length;b<h;b++)r=this.endPoints[b].x*j-this.endPoints[b].y*f,m=this.endPoints[b].x*f+this.endPoints[b].y*j,this.endPoints[b].x=
r,this.endPoints[b].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,d,c){k=this.evaluator;b=this.space;l=e(k.evalExpression(this.width));a.lineWidth=0<l?l:1E-6;n=k.evalExpression(this.size);0>n&&(n=0);a.fillStyle=d.getColor();a.strokeStyle=c.getColor();a.lineCap="round";q=10+a.lineWidth;u=0==a.lineWidth%2?0:0.5;this.abs_coord?
(h=e(this.endPoints[0].x),s=e(this.endPoints[0].y),v=e(this.endPoints[1].x),y=e(this.endPoints[1].y)):(h=e(b.getAbsoluteX(this.endPoints[0].x)),s=e(b.getAbsoluteY(this.endPoints[0].y)),v=e(b.getAbsoluteX(this.endPoints[1].x)),y=e(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(h+u,s+u);a.lineTo(v+u,y+u);a.stroke();a.beginPath();a.arc(h,s,n,0,g,!0);a.arc(v,y,n,0,g,!0);a.fill();this.text!=[""]&&(p=parseInt((h+v)/2)-3,t=parseInt((s+y)/2)+3,this.uber.drawText.call(this,a,this.text,p+q,t-
q,this.color,this.font,"start","alphabetic",k.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g=Math.round,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s,v,y;a.Arrow=function(b,d){this.width=b.evaluator.parser.parse("5");this.size=b.evaluator.parser.parse("2");this.spear=b.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,b,d)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){k=
this.evaluator;b=k.evalExpression(this.expresion);this.endPoints=[];for(var h=0,e=b.length;h<e;h++)this.endPoints[h]={x:b[h][0],y:b[h][1]};if(this.rotateExp){c=a.degToRad(k.evalExpression(this.rotateExp));d=Math.cos(c);j=Math.sin(c);h=0;for(e=this.endPoints.length;h<e;h++)f=this.endPoints[h].x*d-this.endPoints[h].y*j,r=this.endPoints[h].x*j+this.endPoints[h].y*d,this.endPoints[h].x=f,this.endPoints[h].y=r}};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=
function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(b,d,c){k=this.evaluator;m=this.space;k.evalExpression(this.size);p=k.evalExpression(this.width);0>p&&(p=0);t=Math.ceil(p/2);n=m.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);u=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=d.getColor();b.strokeStyle=c.getColor();b.lineWidth=2;this.abs_coord?
(h=g(this.endPoints[0].x),s=g(this.endPoints[0].y),v=g(this.endPoints[1].x),y=g(this.endPoints[1].y)):(h=g(m.getAbsoluteX(this.endPoints[0].x)),s=g(m.getAbsoluteY(this.endPoints[0].y)),v=g(m.getAbsoluteX(this.endPoints[1].x)),y=g(m.getAbsoluteY(this.endPoints[1].y)));d=k.evalExpression(this.spear);0>d&&(d=0);b.save();b.translate(h,s,u);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?b.rotate(this.angle):b.rotate(-this.angle):(u*=n,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&
0<=this.vect.y?b.rotate(-this.angle):b.rotate(this.angle));b.beginPath();b.moveTo(-t,e(-t));b.lineTo(e(u-d-p),e(-t));b.lineTo(e(u-2*d),e(-d-t));b.lineTo(e(u),0);b.lineTo(e(u-2*d),e(d+t));b.lineTo(e(u-d-p),e(t));b.lineTo(-t,e(t));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(l=parseInt((h+v)/2)-3,q=parseInt((s+y)/2)+3,this.uber.drawText.call(this,b,this.text,l,q,c,this.font,"start","alphabetic",k.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e=Math.round,g,k,b,c,d,j,f,r,m,l,q,p;a.Polygon=function(b,d){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,d);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){g=this.evaluator;b=g.evalExpression(this.expresion);for(var e=0,k=b.length;e<k;e++)this.endPoints[e]={x:b[e][0],y:b[e][1]};if(this.rotateExp){c=a.degToRad(g.evalExpression(this.rotateExp));d=Math.cos(c);j=Math.sin(c);e=0;for(k=this.endPoints.length;e<
k;e++)f=this.endPoints[e].x*d-this.endPoints[e].y*j,r=this.endPoints[e].x*j+this.endPoints[e].y*d,this.endPoints[e].x=f,this.endPoints[e].y=r}};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Polygon.prototype.drawAux=function(a,b,d){g=this.evaluator;k=this.space;m=e(g.evalExpression(this.width));a.lineWidth=0<m?m:1E-6;a.strokeStyle=d.getColor();a.lineCap="round";a.lineJoin=
"round";l=0<m?0.5:0;q=this.abs_coord?e(this.endPoints[0].x):e(k.getAbsoluteX(this.endPoints[0].x));p=this.abs_coord?e(this.endPoints[0].y):e(k.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(q+l,p+l);d=1;for(var c=this.endPoints.length;d<c;d++)q=this.abs_coord?e(this.endPoints[d].x):e(k.getAbsoluteX(this.endPoints[d].x)),p=this.abs_coord?e(this.endPoints[d].y):e(k.getAbsoluteY(this.endPoints[d].y)),a.lineTo(q+l,p+l);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,g,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s,v,y,B,x;a.Arc=function(b,d){this.width=b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=b.evaluator.parser.parse("1");this.init=b.evaluator.parser.parse("0");this.end=b.evaluator.parser.parse("90");a.Graphic.call(this,b,d)};a.extend(a.Arc,a.Graphic);a.Arc.prototype.update=function(){g=this.evaluator;k=g.evalExpression(this.center);this.exprX=k[0][0];
this.exprY=k[0][1];this.rotateExp&&(b=a.degToRad(g.evalExpression(this.rotateExp)),c=Math.cos(b),d=Math.sin(b),j=this.exprX*c-this.exprY*d,f=this.exprX*d+this.exprY*c,this.exprX=j,this.exprY=f);var h=g.evalExpression(this.init),e=g.evalExpression(this.end);"(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type?(r=h[0][0],m=h[0][1],l=e[0][0],q=e[0][1],
this.vectors?this.abs_coord&&(m=-m,q=-q):this.abs_coord?(r-=this.exprX,m=-m+this.exprY,l-=this.exprX,q=-q+this.exprY):(r-=this.exprX,m-=this.exprY,l-=this.exprX,q-=this.exprY),p=Math.acos((1*r+0*m)/Math.sqrt(r*r+m*m)),t=Math.acos((1*l+0*q)/Math.sqrt(l*l+q*q)),0<r&&(0<m&&this.abs_coord)&&(p=2*Math.PI-p),0<r&&(0>m&&!this.abs_coord)&&(p=2*Math.PI-p),0>r&&(0>m&&!this.abs_coord)&&(p=2*Math.PI-p),0>r&&(0<m&&this.abs_coord)&&(p=2*Math.PI-p),0<l&&(0<q&&this.abs_coord)&&(t=2*Math.PI-t),0<l&&(0>q&&!this.abs_coord)&&
(t=2*Math.PI-t),0>l&&(0>q&&!this.abs_coord)&&(t=2*Math.PI-t),0>l&&(0<q&&this.abs_coord)&&(t=2*Math.PI-t),n=Math.min(p,t),u=Math.max(p,t),p=n,t=u,t-p>Math.PI&&this.abs_coord&&(p=u,t=n),t-p<=Math.PI&&!this.abs_coord&&(p=u,t=n),this.iniAng=p,this.endAng=t,this.drawPoints=!0):(this.iniAng=a.degToRad(h),this.endAng=a.degToRad(e),this.drawAngle=!0)};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,
this.trace)};a.Arc.prototype.drawAux=function(a,b,d){g=this.evaluator;h=this.space;y=g.evalExpression(this.radius);0>y&&(y=0);x=e(g.evalExpression(this.width));a.lineWidth=0<x?x:1E-6;a.lineCap="round";a.strokeStyle=d.getColor();this.drawAngle?(this.abs_coord?(s=e(this.exprX),v=e(this.exprY)):(s=e(h.getAbsoluteX(this.exprX)),v=e(h.getAbsoluteY(this.exprY)),y*=h.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(B=this.iniAng,this.iniAng=this.endAng,this.endAng=B)):this.drawPoints&&
(this.abs_coord?(s=e(this.exprX),v=e(this.exprY)):(s=e(h.getAbsoluteX(this.exprX)),v=e(h.getAbsoluteY(this.exprY)),y*=h.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(s,v),a.arc(s,v,y,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(s,v,y,this.iniAng,this.endAng,void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,s+4,v-2,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),
this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s;a.Text=function(b,d){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,d);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){e=this.evaluator;g=e.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1];
this.rotateExp&&(k=a.degToRad(e.evalExpression(this.rotateExp)),b=Math.cos(k),c=Math.sin(k),d=this.exprX*b-this.exprY*c,j=this.exprX*c+this.exprY*b,this.exprX=d,this.exprY=j)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,b){s=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(l=this.text,this.ascent=0):l=this.splitText(this.text.toString(s,
this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,a,l,parseInt(this.exprX)+5,parseInt(this.exprY)+this.ascent,b,this.font,this.align,"alphabetic",s,this.fixed)};a.Text.prototype.splitText=function(a){e=this.evaluator;f=e.evalExpression(this.width);l=[];this.ctx.font=this.font;if(20<=f&&"undefined"!=a.type){for(var b=0,d=a.length;b<d;b++)r=a[b],m=this.ctx.measureText(r).width,m>f?l=l.concat(this.splitWords(r,f)):l.push(r);q=Math.floor(1.2*this.fontSize)*l.length;e.setVariable("_Text_H_",
q);return l}e.setVariable("_Text_H_",0);e.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,b){p=a;t=[];n="";h=0;for(var d,c=0,f=a.length;c<f;c++)u=p.charAt(c)," "===u&&(lastIndexOfWhite=c),n+=u,Math.round(this.ctx.measureText(n).width)>b&&(d=a.substring(h,c+1)," "!==u&&(-1===d.indexOf(" ")?(lastIndexOfWhite=c,c--):c=lastIndexOfWhite),t.push(a.substring(h,lastIndexOfWhite)),n="",h=c+1);t.push(a.substring(h));return t};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e=Math.round,g,k,b,c,d,j,f,r,m,l,q,p,t,n;a.Image=function(b,d){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,d);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){g=this.evaluator;k=g.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];this.rotateExp&&(b=a.degToRad(g.evalExpression(this.rotateExp)),c=Math.cos(b),d=Math.sin(b),j=this.exprX*c-this.exprY*d,f=this.exprX*d+this.exprY*
c,this.exprX=j,this.exprY=f);4==k[0].length&&(this.centered=!0,this.scaleX=k[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=k[0][3],0==this.scaleY&&(this.scaleY=1E-5));k[1]&&2==k[1].length&&(this.centered=!0,this.scaleX=k[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=k[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((r=g.evalExpression(this.file))||""==r)this.img=this.parent.getImage(r)};a.Image.prototype.draw=function(){this.uber.draw.call(this)};a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};
a.Image.prototype.drawAux=function(b){g=this.evaluator;m=this.space;this.img&&(this.img.ready&&this.img.complete)&&(l=this.centered?0:this.img.width/2,q=this.centered?0:this.img.height/2,p=this.abs_coord?e(this.exprX):e(m.getAbsoluteX(this.exprX)),t=this.abs_coord?e(this.exprY):e(m.getAbsoluteY(this.exprY)),n=a.degToRad(-g.evalExpression(this.inirot)),b.translate(p+l,t+q),b.rotate(n),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=g.evalExpression(this.opacity)),b.drawImage(this.img,
-this.img.width/2,-this.img.height/2),b.setTransform(1,0,0,1,0,0),b.globalAlpha=1)};return a}(descartesJS||{}),descartesJS=function(a){function e(a,b,d){f=4*(b+d*a.width);return{r:a.data[f],g:a.data[f+1],b:a.data[f+2],a:a.data[f+3]}}if(a.loadLib)return a;var g,k,b,c,d,j,f;a.Fill=function(b,d){a.Graphic.call(this,b,d)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){g=this.evaluator.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,
this.color,this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=function(a,g){g.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(k=parseInt(this.exprX),b=parseInt(this.exprY)):(k=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>k||0>b||k>=this.space.w||b>=this.space.h)){c=[{x:k,y:b}];for(j=e(imageData,k,b);0<c.length;){d=c.pop();k=d.x;b=d.y;var l=e(imageData,k,b);if(j.r===l.r&&j.g===
l.g&&j.b===l.b&&j.a===l.a){var l=imageData,q=g;f=4*(k+b*l.width);l.data[f+0]=q.r;l.data[f+1]=q.g;l.data[f+2]=q.b;l.data[f+3]=255-q.a;0<k&&c.push({x:k-1,y:b});k<imageData.width-1&&c.push({x:k+1,y:b});c.push({x:k,y:b-1});c.push({x:k,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;var g=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g;a.Macro=function(k,b){this.expresion=void 0;this.inirot=k.evaluator.parser.parse("0");
a.Graphic.call(this,k,b);for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c]);this.graphics=[];c=k.lessonParser;var d=new a.Tokenizer;if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var j=this.evaluator.evalExpression(this.expresion),f;j&&((f=document.getElementById(j))&&"descartes/macro"==f.type?f=f.text:(f=a.openExternalFile(j))&&!f.match(/tipo_de_macro/g)&&(f=null));var r,m;if(f){m=f.replace(/&aacute;/g,
"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").replace(/\r/g,"").split("\n");f=[];for(var j=0,l=m.length;j<l;j++)r=m[j].indexOf("="),-1!==r&&
(r=m[j].substring(0,r),("id"===e[r]||"type"===e[r])&&f.push(c.split(m[j])));for(var q,p,t,n,j=0,l=f.length;j<l;j++){n=(q=f[j]||[])&&q[0]&&"id"===q[0][0];m=0;for(r=q.length;m<r;m++)if(p=q[m][0].indexOf("."),-1!==p&&!n?(p=e[q[m][0].substring(p+1)],q[m][0]=this.name+"."+q[m][0]):p=e[q[m][0]],!("font"===p||("fill"===p||"color"===p||"arrow"===p)&&"("!==q[m][1].charAt(0)||"file"===p&&q[m][1].match(g)||"id"!==p&&void 0!==e[q[m][1]]))if("text"==p)if(q[m][1].match(/\{\\rtf1/)){p=q[m][1];var u=this;t=function(a,
b){for(var c=d.tokenize(b.replace(/\&squot;/g,"'")),f=0,h=c.length;f<h;f++)"identifier"==c[f].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+c[f].value+"-")&&(c[f].value=u.name+"."+c[f].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+d.flatTokens(c)};p=p.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,t);p=p.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,
t);q[m][1]=p}else{t=c.parseText(q[m][1]).textElementsMacros;for(var h=0,s=t.length;h<s;h++){p=d.tokenize(t[h].replace(/\&squot;/g,"'"));for(var v=0,y=p.length;v<y;v++)"identifier"===p[v].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+p[v].value+"-")&&(p[v].value=this.name+"."+p[v].value);p=d.flatTokens(p).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");t[h]=
p.substring(1,p.length-1)}q[m][1]=t.join("")}else{p=d.tokenize(q[m][1]);t=0;for(h=p.length;t<h;t++)"identifier"===p[t].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+p[t].value+"-")&&(p[t].value=this.name+"."+p[t].value);q[m][1]=d.flatTokens(p)}}j=0;for(l=f.length;j<l;j++)if(f[j][0]){q="";n=!1;m=0;for(r=f[j].length;m<r;m++)"type"===e[f[j][m][0]]&&(q="espacio='"+this.spaceID+"' ",
n=!0),q=q+f[j][m][0]+"='"+f[j][m][1]+"' ";f[j]=q;n?this.graphics.push(c.parseGraphic(f[j],this.abs_coord,this.background,this.inirot)):c.parseAuxiliar(f[j])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}};a.Macro.prototype.drawAux=function(a){for(var b=0,c=this.graphics.length;b<c;b++)this.inipos&&(this.graphics[b].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*
this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[b].draw(),a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sqrt,g=Math.sin,k=Math.cos,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s;a.norm3D=function(a){return e(a.x*a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(d){b=a.norm3D(d);if(0===b)return{x:0,y:0,z:0};if(1===b)return{x:d.x,y:d.y,z:d.z};b=1/b;return{x:d.x*b,y:d.y*b,z:d.z*b}};a.dotProduct3D=function(a,b){return a.x*b.x+a.y*b.y+
a.z*b.z};a.crossProduct3D=function(a,b){return{x:a.y*b.z-a.z*b.y,y:a.z*b.x-a.x*b.z,z:a.x*b.y-a.y*b.x}};a.scalarProduct3D=function(a,b){return{x:a.x*b,y:a.y*b,z:a.z*b}};a.subtract3D=function(a,b){return{x:a.x-b.x,y:a.y-b.y,z:a.z-b.z}};a.add3D=function(a,b){return{x:a.x+b.x,y:a.y+b.y,z:a.z+b.z}};a.equals3DEpsilon=function(a,b,d){return Math.abs(a.x-b.x)<=d&&Math.abs(a.y-b.y)<=d&&Math.abs(a.z-b.z)<=d};a.Vector4D=function(a,b,d,c){this.x=a||0;this.y=b||0;this.z=d||0;this.w=c||0};a.Matrix4x4=function(a,
b,d,c,f,h,e,j,k,l,n,g,m,p,r,q){this.a00=a||0;this.a01=b||0;this.a02=d||0;this.a03=c||0;this.a10=f||0;this.a11=h||0;this.a12=e||0;this.a13=j||0;this.a20=k||0;this.a21=l||0;this.a22=n||0;this.a23=g||0;this.a30=m||0;this.a31=p||0;this.a32=r||0;this.a33=q||0};a.Matrix4x4.prototype.setIdentity=function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=
function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*
b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(b){c=g(b);d=k(b);l=this.a10;q=this.a11;p=this.a12;t=this.a13;n=this.a20;u=this.a21;h=this.a22;s=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,l*d+n*c,q*d+u*c,p*d+h*c,t*d+s*c,l*-c+n*d,q*-c+u*d,p*-c+h*d,t*-c+s*d,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){c=g(b);d=k(b);j=this.a00;f=this.a01;r=this.a02;
m=this.a03;n=this.a20;u=this.a21;h=this.a22;s=this.a23;return new a.Matrix4x4(j*d+n*-c,f*d+u*-c,r*d+h*-c,m*d+s*-c,this.a10,this.a11,this.a12,this.a13,j*c+n*d,f*c+u*d,r*c+h*d,m*c+s*d,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){c=g(b);d=k(b);j=this.a00;f=this.a01;r=this.a02;m=this.a03;l=this.a10;q=this.a11;p=this.a12;t=this.a13;return new a.Matrix4x4(j*d+l*c,f*d+q*c,r*d+p*c,m*d+t*c,j*-c+l*d,f*-c+q*d,r*-c+p*d,m*-c+t*d,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,
this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function e(a){a.lineWidth=1;a.fillStyle=this.backColor.getColor();a.strokeStyle=this.frontColor.getColor();a.beginPath();a.arc(this.newV[0].x,this.newV[0].y,this.size+0.5,0,d);a.fill();a.stroke()}function g(a,b){a.lineCap=j;a.lineJoin=f;this.frontColor.getColor();this.backColor.getColor();a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var d=1,c=this.newV.length;d<c;d++)a.lineTo(this.newV[d].x,this.newV[d].y);a.closePath();
"color"===this.model?(a.fillStyle=0<=this.direction?this.backColor.getColor():this.frontColor.getColor(),a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=0<=this.direction?b.computeColor(this.backColor,this,"metal"===this.model):b.computeColor(this.frontColor,this,"metal"===this.model),a.fill()):"wire"===this.model&&(a.lineWidth=1.25,a.strokeStyle=this.frontColor.getColor(),a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function k(a){t=
this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,this.familyValue);this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor.getColor(),this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,t)}function b(a){a.lineCap=j;a.lineJoin=f;a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor.getColor();a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);a.lineTo(this.newV[1].x,this.newV[1].y);a.stroke()}
function c(b,d,c){r=a.subtract3D(b,d);m=a.subtract3D(b,c);return a.normalize3D(a.crossProduct3D(r,m))}if(a.loadLib)return a;var d=2*Math.PI,j="round",f="round",r,m,l,q,p,t;a.Primitive3D=function(a){for(var d in a)a.hasOwnProperty(d)&&(this[d]=a[d]);this.newV=[];"vertex"===this.type?this.draw=e:"face"===this.type?(this.normal=c(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=g):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,
this.draw=k):"edge"===this.type&&(this.draw=b);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z})};a.Primitive3D.prototype.computeDepth=function(b){this.average={x:0,y:0,z:0};for(var d=0,f=this.vertices.length;d<f;d++)this.newV[d]=b.rotateVertex(this.vertices[d]),this.average.x+=this.newV[d].x,this.average.y+=this.newV[d].y,this.average.z+=this.newV[d].z;this.average=a.scalarProduct3D(this.average,1/f);2<this.vertices.length&&(this.normal=c(this.newV[0],
this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));d=this.depth=0;for(f=this.vertices.length;d<f;d++)this.newV[d]=b.project(this.newV[d]),this.depth+=this.newV[d].z;this.depth/=f};a.Primitive3D.prototype.drawText=function(b,d,c,f,e,j,k,g,m,r,t){if("rtfNode"==d.type)b.fillStyle=e,b.strokeStyle=e,b.textBaseline="alphabetic",d.draw(b,c,f,m,r,k,t);else{"simpleText"===d.type&&(d=d.toString(m,r).split("\\n"));c+=j.match("Arial")?-2:j.match("Times")?-2:0;l=this.evaluator;
b.fillStyle=a.getColor(l,e);b.font=j;b.textAlign=k;b.textBaseline=g;q=1.2*this.fontSize||0;e=0;for(j=d.length;e<j;e++)p=d[e],this.border&&b.strokeText(p,c,f+q*e),b.fillText(p,c,f+q*e)}};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var d=null,c=null,f=0,e=0,j=0,k=b.vertices.length;j<k;j++){var l=this.intersection(b.vertices[j],b.vertices[(j+1)%k]);if(null!==l)if(null===d){if(d=l,f=j,2===b.vertices.length){c=d;break}}else if(!a.equals3DEpsilon(l,d,1E-8)){c=l;e=j;break}}if(null!==
d&&null!==c){var j=this.isInterior(d)||this.isInterior(c),g=null,m=null;if(!j&&3<=b.vertices.length)for(var k=0,p=this.vertices.length;k<p;k++)if(l=b.intersection(this.vertices[k],this.vertices[(k+1)%p]),null!==l)if(null===g)g=l;else if(!a.equals3DEpsilon(l,g,1E-8)){m=l;break}if(j||null!==g&&null!==m&&b.isInterior(g)&&b.isInterior(m)){m=!0;p=b.vertices;g=l=null;if(2===p.length)a.equals(d,p[0],1E-8)||a.equals(d,p[1],1E-8)?m=!1:(l=[],l[0]=p[0],l[1]=d,g=[],g[0]=d,g[1]=p[1]);else for(var l=[],g=[],r=
0,j=k=0;j<p.length;j++)j<f?l[r++]=p[j]:j==f?(l[r++]=p[j],l[r++]=d,g[k++]=d):j<e?g[k++]=p[j]:j==e?(g[k++]=p[j],g[k++]=c,l[r++]=c):l[r++]=p[j];if(m)return d=[],d[0]=new a.Primitive3D({vertices:l,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),d[0].normal=b.normal,d[1]=new a.Primitive3D({vertices:g,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),d[1].normal=b.normal,d}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&
a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var d=a.dotProduct3D(b.vertices[0],b.normal),c=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(d-c))return!0;for(var f=1,e=this.vertices.length;f<e;f++){var j=a.dotProduct3D(this.vertices[f],b.normal);if(1E-8>Math.abs(d-j)||j>d&&c<d||j<d&&c>d)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,d){if(0<this.vertices.length){var c=a.subtract3D(d,b),f=a.dotProduct3D(c,this.normal);if(0!==f&&(f=a.dotProduct3D(a.subtract3D(this.vertices[0],
b),this.normal)/f,-1E-8<f&&1.00000001>f))return a.add3D(b,a.scalarProduct3D(c,f))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var d=0,c=a.subtract3D(this.vertices[0],b),f=0,e=this.vertices.length;f<e;f++){var j=a.subtract3D(this.vertices[(f+1)%e],b),k=a.dotProduct3D(a.crossProduct3D(c,j),this.normal);if(1E-8>Math.abs(k)){if(0>a.dotProduct3D(c,j))break}else{if(0>d&&0<k||0<d&&0>k)return!1;c=j;d=k}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e={x:0,y:0,z:0},g,k,b,c,d,j,f,r;a.Graphic3D=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");this.drawif=c.parse("1");this.abs_coord=!1;this.family="";this.family_interval=c.parse("[0,1]");this.family_steps=c.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;
this.text="";this.decimals=c.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=c.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=c.parse("(0,0,0)");this.model="color";for(var f in d)d.hasOwnProperty(f)&&(this[f]=d[f]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=c.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);
this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10;this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=c.parse(this.inirot);this.endrot=c.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=
new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,d=0,c=a.length;d<c;d++)if(b=a[d],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){g=this.evaluator;k=g.evalExpression(this.family_interval);this.familyInf=k[0][0];this.familySup=k[0][1];this.fSteps=Math.round(g.evalExpression(this.family_steps));this.family_sep=
0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){g=this.evaluator;this.getFamilyValues();b=g.getVariable(this.family);if(0<=this.fSteps)for(var a=0,d=this.fSteps;a<=d;a++)g.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,g.evalExpression(this.drawif)&&this.buildPrimitives();g.setVariable(this.family,b)};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.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(d[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(d[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(d[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(d[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(d[0][1])),
this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(d[0][2])));d=this.evaluator.evalExpression(this.inipos);e={x:d[0][0],y:d[0][1],z:d[0][2]};this.iniposM=this.iniposM.setIdentity().translate(e);d=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(d[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(d[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(d[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(d[0][0])),
this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(d[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(d[0][2])));d=this.evaluator.evalExpression(this.endpos);e={x:d[0][0],y:d[0][1],z:d[0][2]};this.endposM=this.endposM.setIdentity().translate(e)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?c=this.inirotM.multiplyVector4(a):(c=this.inirotM_X.multiplyVector4(a),c=this.inirotM_Y.multiplyVector4(c),c=this.inirotM_Z.multiplyVector4(c));c=this.iniposM.multiplyVector4(c);
this.endrotEuler?c=this.endrotM.multiplyVector4(c):(c=this.endrotM_X.multiplyVector4(c),c=this.endrotM_Y.multiplyVector4(c),c=this.endrotM_Z.multiplyVector4(c));return c=this.endposM.multiplyVector4(c)};a.Graphic3D.prototype.parseExpression=function(){d=this.expresion.split("=");j=d[0];f=[];for(var a=1;a<d.length;a++)j+="=",r=d[a].lastIndexOf(" "),j+=-1!==r?d[a].substring(0,r):d[a],f.push(this.evaluator.parser.parse(j,!0)),j=d[a].substring(r+1);return f};var m;a.Graphic3D.prototype.splitFace=function(a){for(var b=
0,d=this.primitives.length;b<d;b++)if(m=[],"face"===this.primitives[b].type){for(var c=0,f=a.primitives.length;c<f;c++)"face"===a.primitives[c].type?m=m.concat(this.primitives[b].splitFace(a.primitives[c])):m.push(a.primitives[c]);a.primitives=m}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c;a.Point3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();
g=e.evalExpression(this.expresion);k=g[0][0];b=g[0][1];c=g[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(k,b,c,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:e.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(k,b,c,1))],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,
evaluator:e,text:this.text,family:this.family,familyValue:this.familyValue}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d;a.Segment3D=function(b,d){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,d)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=expr[0][0];g=expr[0][1];k=expr[0][2];b=expr[1][0];c=expr[1][1];
d=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,g,k,1)),this.transformVertex(new a.Vector4D(b,c,d,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j;a.Surface3D=function(b,d){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");a.Graphic3D.call(this,
b,d);this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();k=e.getVariable("x");k=e.getVariable("y");k=e.getVariable("z");g=e.getVariable("u");k=e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);b=e.evalExpression(this.Nu);c=e.evalExpression(this.Nv);d=[];for(var f=0;f<=b;f++){e.setVariable("u",f/b);for(var r=0;r<=c;r++){e.setVariable("v",r/c);for(var m=0,l=this.expresion.length;m<
l;m++)e.evalExpression(this.expresion[m]);d.push(this.transformVertex(new a.Vector4D(e.getVariable("x"),e.getVariable("y"),e.getVariable("z"),1)))}}for(f=0;f<b;f++)for(r=0;r<c;r++)j=[],j.push(d[r+f*c+f]),j.push(d[r+1+f*c+f]),j.push(d[r+2+(f+1)*c+f]),j.push(d[r+1+(f+1)*c+f]),this.primitives.push(new a.Primitive3D({vertices:j,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}));e.setVariable("x",void 0);e.setVariable("y",void 0);e.setVariable("z",void 0);e.setVariable("u",
g);e.setVariable("v",k)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d;a.Polygon3D=function(b,d){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,d)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);for(var j=0,f=expr.length-1;j<f;j++)e=expr[j][0],g=expr[j][1],k=expr[j][2],b=expr[j+1][0],c=expr[j+1][1],d=expr[j+1][2],
this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,g,k,1)),this.transformVertex(new a.Vector4D(b,c,d,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d;a.Curve3D=function(b,d){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,d);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=
function(){evaluator=this.evaluator;this.updateMVMatrix();b=evaluator.getVariable("x");c=evaluator.getVariable("y");d=evaluator.getVariable("z");k=evaluator.getVariable("u");evaluator.setVariable("u",0);g=evaluator.evalExpression(this.Nu);e=[];for(var j=0;j<=g;j++){evaluator.setVariable("u",j/g);for(var f=0,r=this.expresion.length;f<r;f++)evaluator.evalExpression(this.expresion[f]);e.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),
1)))}console.log(e);j=0;for(f=e.length-1;j<f;j++)this.primitives.push(new a.Primitive3D({vertices:[e[j],e[j+1]],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}));evaluator.setVariable("x",b);evaluator.setVariable("y",d);evaluator.setVariable("z",c);evaluator.setVariable("u",k)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j,f,r;a.Triangle3D=function(b,d){a.Graphic3D.call(this,b,d)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=
function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=expr[0][0];g=expr[0][1];k=expr[0][2];b=expr[1][0];c=expr[1][1];d=expr[1][2];j=expr[2][0];f=expr[2][1];r=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,g,k,1)),this.transformVertex(new a.Vector4D(j,f,r,1)),this.transformVertex(new a.Vector4D(b,c,d,1))],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Face3D=function(e,k){a.Graphic3D.call(this,e,k)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=[];for(var g=expr.length-1;0<=g;g--)e.push(this.transformVertex(new a.Vector4D(expr[g][0],expr[g][1],expr[g][2],1)));this.primitives.push(new a.Primitive3D({vertices:e,type:"face",frontColor:this.color,
backColor:this.backcolor,edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c;a.Polireg3D=function(b,c){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,c)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();e=evaluator.evalExpression(this.Nu);g=[this.transformVertex(new a.Vector4D(0,0,0,1))];
k=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/2;c=2*Math.PI/e;for(var d=0;d<e;d++)g.push(this.transformVertex(new a.Vector4D(k*Math.cos(c*d),b*Math.sin(c*d),0,1)));for(d=0;d<e;d++)this.primitives.push(new a.Primitive3D({vertices:[g[0],d+2<=e?g[d+2]:g[1],g[d+1]],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b;a.Text3D=function(b,d){a.Graphic3D.call(this,
b,d)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){e=this.evaluator;g=e.evalExpression(this.expresion);k=g[0][0];b=g[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(k,b,0,1)],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:e,text:this.text,family:this.family,familyValue:this.familyValue}))};return a}(descartesJS||{}),descartesJS=function(a){function e(a,
b,d,c,f){g.call(this,a/1.8,a/1.8,a/1.8,c,f)}function g(a,b,d,c,f){a/=2;b/=2;d/=2;this.changeGeometry(a,b,d,c,f)||(this.vertices=[new n(a,d,b,1),new n(a,-d,b,1),new n(a,d,-b,1),new n(a,-d,-b,1),new n(-a,d,b,1),new n(-a,-d,b,1),new n(-a,d,-b,1),new n(-a,-d,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,d,c,f))}function k(a,b,d,c,f){a/=2;this.changeGeometry(a,b,d,c,f)||(this.vertices=[new n(0,0,a,1),new n(-0.49*a,-0.86*a,-0.32*a,1),new n(-0.49*a,
0.86*a,-0.32*a,1),new n(1*a,0,-0.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,b,d,c,f))}function b(a,b,d,c,f){a/=2;this.changeGeometry(a,b,d,c,f)||(this.vertices=[new n(0,0,a,1),new n(a,0,0,1),new n(-a,0,0,1),new n(0,a,0,1),new n(0,-a,0,1),new n(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,d,c,f))}function c(b,d,c,f,e){b/=3.4;if(!this.changeGeometry(b,d,c,f,e)){C=b/D;A=b*D;this.vertices=[new n(b,b,b,1),new n(b,
b,-b,1),new n(b,-b,b,1),new n(b,-b,-b,1),new n(-b,b,b,1),new n(-b,b,-b,1),new n(-b,-b,b,1),new n(-b,-b,-b,1),new n(0,C,A,1),new n(0,C,-A,1),new n(0,-C,A,1),new n(0,-C,-A,1),new n(C,A,0,1),new n(C,-A,0,1),new n(-C,A,0,1),new n(-C,-A,0,1),new n(A,0,C,1),new n(A,0,-C,1),new n(-A,0,C,1),new n(-A,0,-C,1)];z=(new a.Matrix4x4).setIdentity().rotateY(-p/6);for(var h=0,j=this.vertices.length;h<j;h++)this.vertices[h]=z.multiplyVector4(this.vertices[h]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,4,14,12,0],
[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,d,c,f,e)}}function d(b,d,c,f,e){b/=4;if(!this.changeGeometry(b,d,c,f,e)){A=b*D;this.vertices=[new n(0,b,A,1),new n(0,b,-A,1),new n(0,-b,A,1),new n(0,-b,-A,1),new n(b,A,0,1),new n(b,-A,0,1),new n(-b,A,0,1),new n(-b,-A,0,1),new n(A,0,b,1),new n(A,0,-b,1),new n(-A,0,b,1),new n(-A,0,-b,1)];this.faces=[[10,0,2],[0,8,2],[8,5,2],[5,7,2],[7,10,2],[6,0,10],
[11,6,10],[7,11,10],[7,3,11],[5,3,7],[9,3,5],[8,9,5],[4,9,8],[0,4,8],[6,4,0],[11,3,1],[6,11,1],[4,6,1],[9,4,1],[3,9,1]];z=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var h=0,j=this.vertices.length;h<j;h++)this.vertices[h]=z.multiplyVector4(this.vertices[h]);this.updateValues(b,d,c,f,e)}}function j(a,b,d,c,f){a/=2;this.isSphere?d=b=a:(b/=2,d/=2);if(!this.changeGeometry(a,b,d,c,f)){this.vertices=[new n(0,0,b,1)];for(var e=1;e<c;e++){x=e*p/c;for(var h=0;h<f;h++)B=h*t/f,s=a*l(x)*q(B),v=d*l(x)*
l(B),y=b*q(x),this.vertices.push(new n(s,v,y,1))}this.vertices.push(new n(0,0,-b,1));this.faces=[];for(e=0;e<f;e++)this.faces.push([0,(e+1)%f+1,e%f+1]);for(e=1;e<c-1;e++)for(h=0;h<f;h++)this.faces.push([h+1+(e-1)*f,(h+1)%f+1+(e-1)*f,(h+1)%f+1+e*f,h+1+e*f]);for(e=0;e<f;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+e,this.vertices.length-1-f+(e+1)%f]);this.updateValues(a,b,d,c,f)}}function f(a,b,d,c,f){a/=2;b/=2;d/=2;if(!this.changeGeometry(a,b,d,c,f)){this.vertices=[];for(var e=
0;e<f;e++)for(var h=0;h<c;h++)s=a*(f-e)/f*q(h*t/c),v=d*(f-e)/f*l(h*t/c),y=b-2*e*b/f,this.vertices.push(new n(s,v,y,1));this.vertices.push(new n(0,0,-b,1));this.faces=[];for(e=0;e<f-1;e++)for(h=0;h<c;h++)this.faces.push([h+e*c,(h+1)%c+e*c,(h+1)%c+(e+1)*c,h+(e+1)*c]);for(e=0;e<c;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-c+e,this.vertices.length-1-c+(e+1)%c]);this.updateValues(a,b,d,c,f)}}function r(a,b,d,c,f){a/=2;b/=2;d/=2;if(!this.changeGeometry(a,b,d,c,f)){this.vertices=
[];for(var e=0;e<f+1;e++)for(var h=0;h<c;h++)s=a*q(h*t/c),v=d*l(h*t/c),y=b-2*e*b/f,this.vertices.push(new n(s,v,y,1));this.faces=[];for(e=0;e<f;e++)for(h=0;h<c;h++)this.faces.push([h+e*c,(h+1)%c+e*c,(h+1)%c+(e+1)*c,h+(e+1)*c]);this.updateValues(a,b,d,c,f)}}function m(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var d=0,c=this.fileData.length;d<c;d++)G=this.fileData[d],G.match(/^V\(/)?(F=G.substring(2,G.length-1).split(",").map(b),this.vertices.push(new n(F[0]||
0,F[1]||0,F[2]||0,1))):G.match(/^F\(/)&&(F=G.substring(2,G.length-1).split(",").map(a),this.faces.push(F.reverse()))}if(a.loadLib)return a;var l=Math.sin,q=Math.cos,p=Math.PI,t=2*p,n,u,h,s,v,y,B,x,D=1.6180339887,C,A,z,G,F;a.OtherGeometry=function(h,l){this.width=h.evaluator.parser.parse("2");this.height=h.evaluator.parser.parse("2");this.length=h.evaluator.parser.parse("2");n=a.Vector4D;a.Graphic3D.call(this,h,l);switch(this.type){case "cube":this.buildGeometry=e;break;case "box":this.buildGeometry=
g;break;case "tetrahedron":this.buildGeometry=k;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=j;break;case "dodecahedron":this.buildGeometry=c;break;case "icosahedron":this.buildGeometry=d;break;case "cone":this.buildGeometry=f;break;case "cylinder":this.buildGeometry=r;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(){u=this.evaluator;this.updateMVMatrix();this.buildGeometry(u.evalExpression(this.width),u.evalExpression(this.height),u.evalExpression(this.length),u.evalExpression(this.Nu),u.evalExpression(this.Nv));for(var b=0,d=this.faces.length;b<d;b++){h=[];for(var c=0,f=this.faces[b].length;c<f;c++)h.push(this.transformVertex(this.vertices[this.faces[b][c]]));this.primitives.push(new a.Primitive3D({vertices:h,type:"face",frontColor:this.color,backColor:this.backcolor,
edges:this.edges,model:this.model}))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,d,c,f){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===d&&this.oldNu===c&&this.oldNv===f};a.OtherGeometry.prototype.updateValues=function(a,b,d,c,f){this.oldWidth=a;this.oldHeight=b;this.oldLength=d;this.oldNv=f;this.oldNu=c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.max,g=Math.min,k=Math.PI,b=Math.cos,c=Math.sin,d=Math.abs,j,f,r,m,l,q,p,t,n,u,h,s,v,
y,B,x,D,C;a.R2=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.set=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return Math.round(e(g(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(e(g(this.y,32E3),-32E3))};a.R2.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};a.R2.prototype.norm2=function(){return this.x*this.x+this.y*this.y};a.R2.prototype.norm=function(){return Math.sqrt(this.norm2())};
a.R2.prototype.distance=function(a){f=this.copy();f.sub(a);return f.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(){j=this.norm();0!=j&&this.div(j)};a.R2.prototype.rotR90=
function(){j=this.x;this.x=this.y;this.y=-j};a.R2.prototype.rotL90=function(){j=this.x;this.x=-this.y;this.y=j};a.R2.prototype.rot=function(a){r=this.copy();q=b(a);p=c(a);this.x=r.x*q-r.y*p;this.y=r.x*p+r.y*q};a.R2.prototype.rot=function(a){this.rot(a*k/180)};a.R2.prototype.intersection=function(b,c,f,j){t=c.x-b.x;n=f.x-j.x;u=f.x-b.x;h=c.y-b.y;s=f.y-j.y;v=f.y-b.y;C=t*s-n*h;return 1E-6<d(C)?(m=(u*s-v*n)/C,l=(-u*h+v*t)/C,0<=m&&1>=m&&0<=l&&1>=l?new a.R2(b.x+t*m,b.y+h*m):null):(c.x-f.x)*v!=(c.y-f.y)*
u?null:b.x!=c.x?(y=g(b.x,c.x),B=e(b.x,c.x),y<=f.x&&f.x<=B?f:y<=j.x&&j.x<=B?j:null):f.x!=j.x?(x=g(f.x,j.x),D=e(f.x,j.x),x<=b.x&&b.x<=D?b:x<=c.x&&c.x<=D?c:null):b.y!=c.y?(y=g(b.y,c.y),B=e(b.y,c.y),y<=f.y&&f.y<=B?f:y<=j.y&&j.y<=B?j:null):f.y!=j.y?(x=g(f.y,j.y),D=e(f.y,j.y),x<=b.y&&b.y<=D?b:x<=c.y&&c.y<=D?c:null):b.x==f.x&&b.y==f.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j,f;a.R2Newton=function(b,c){this.evaluator=b;this.constraint=c;if("=="==this.constraint.value||
"<"==this.constraint.value||"<="==this.constraint.value||">"==this.constraint.value||">="==this.constraint.value)this.sign="<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0];d=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){e=
this.evaluator;j=e.getVariable("x");f=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);e.setVariable("x",e.getVariable("x")+1E-12);g=e.evalExpression(this.constraint);d.x=(g-this.f0)/1E-12;d.x=!isNaN(d.x)?d.x:Infinity;e.setVariable("x",e.getVariable("x")-1E-12);e.setVariable("y",e.getVariable("y")+1E-12);g=e.evalExpression(this.constraint);d.y=(g-this.f0)/1E-12;d.y=!isNaN(d.y)?d.y:Infinity;e.setVariable("x",j);e.setVariable("y",f);return d};
a.R2Newton.prototype.findZero=function(a){e=this.evaluator;c=a.copy();j=e.getVariable("x");f=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return c;e.setVariable("x",j);e.setVariable("y",f);for(var d=0;256>d;d++)if(k=c.x,b=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=k+this.normal.x,c.y=b+this.normal.y,1E-6>this.normal.norm()){0===
this.normal.x&&0===this.normal.y&&(this.normal.x=c.x-a.x,this.normal.y=c.y-a.y);break}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,g){this.x=a;this.y=g};a.Vector2D.AXIS_X=new a.Vector2D(1,0);a.Vector2D.AXIS_Y=new a.Vector2D(0,1);a.Vector2D.prototype.vectorLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y};a.Vector2D.prototype.angleBetweenVectors=function(a){return Math.acos(this.dotProduct(a)/
(this.vectorLength()*a.vectorLength()))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g=Math.round,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s,v,y,B,x;a.Control=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=this.parser=b.evaluator.parser;this.id="graphic"!==d.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==d.type?100:350;this.h="video"!==d.type?23:120;"graphic"!==d.type&&"audio"!==d.type&&"video"!==d.type?"text"!==
d.type?this.expresion=c.parse("(0,0,100,23)"):(this.expresion=c.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=c.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt="graphic"!==d.type?new a.Color("f0f8ff"):new a.Color("cc0022");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:c.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";
this.drawif=c.parse("1");this.activeif=c.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=c.parse("0");this.decimals=c.parse("2");this.min=c.parse("-Infinity");this.max=c.parse("Infinity");this.incr=c.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var f in d)d.hasOwnProperty(f)&&(this[f]=d[f]);if(("video"===this.type||"audio"===this.type)&&"interior"!==this.region)this.region=
"interior";void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;c=this.evaluator.evalExpression(this.expresion);this.x=g(c[0][0]);this.y=g(c[0][1]);4==c[0].length&&(this.w=g(c[0][2]),this.h=g(c[0][3]));this.actionExec=b.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=
function(){var a=this.parent.spaces,b;if("interior"===this.region)for(var d=0,c=a.length;d<c;d++){if(b=a[d],b.id===this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,b.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,
this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):this.parent.externalSpace.container;if("north"===this.region)return this.parent.northSpace.controls.push(this),this.parent.northSpace.container;if("south"===this.region)return this.parent.southSpace.controls.push(this),this.parent.southSpace.container;if("east"===this.region)return this.parent.eastSpace.controls.push(this),this.parent.eastSpace.container;if("west"===this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;
if("special"===this.region)return this.parent.specialSpace.controls.push(this),this.parent.specialSpace.container}a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a);b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){c=d=j=f=!1;r=this.evaluator.evalExpression(this.expresion);
m=g(r[0][0]);c=g(this.x)!==m;this.x=m;m=g(r[0][1]);d=g(this.y)!==m;this.y=m;4===r[0].length&&(m=g(r[0][2]),j=g(this.w)!==m,this.w=m,m=g(r[0][3]),f=g(this.h)!==m,this.h=m);if(j||f||c||d)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){n=this.parent;l=a+"";q=this.evaluator.evalExpression(this.decimals);p=l.indexOf(".");-1!=p&&(t=l.substring(p+1),t.length>q&&(l=parseFloat(l).toFixed(q)));if(this.fixed&&(2!==n.version||2===n.version&&!this.exponentialif))l=parseFloat(a).toFixed(q);
this.exponentialif&&0!=parseFloat(l)&&(l=this.fixed&&2!==n.version?parseFloat(l).toExponential(q):parseFloat(l).toExponential(),l=l.toUpperCase(),l=l.replace("+",""));return l=l.replace(".",n.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,d){this.linearGradient=this.ctx.createLinearGradient(0,
0,0,d);k=d*d;for(var c=0;c<d;c++)b=e(c-35*d/100),this.linearGradient.addColorStop(c/d,"rgba(0,0,0,"+192*b*b/k/255+")")};a.Control.prototype.getScreenshot=function(){s=this;u=document.createElement("canvas");u.setAttribute("width",s.w);u.setAttribute("height",s.h);h=u.getContext("2d");h.font=s.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";s.canvas&&(v=s.canvas.offsetLeft,y=s.canvas.offsetTop,h.drawImage(s.canvas,v,y));s.label&&(v=s.label.offsetLeft,y=s.label.offsetTop,B=s.label.offsetWidth,
x=s.label.offsetHeight,h.fillStyle="#e0e4e8",h.fillRect(v,y,B,x),h.fillStyle="black",h.textAlign="center",h.textBaseline="middle",h.fillText(s.name,v+B/2,y+x/2));s.field&&(v=s.field.offsetLeft,y=s.field.offsetTop,B=s.field.offsetWidth,x=s.field.offsetHeight,h.fillStyle="white",h.strokeStyle="#666666",h.lineWidth=1,h.fillRect(v,0,B,x),h.strokeRect(v+0.5,0.5,B-1,x-1),h.fillStyle="black",h.textAlign="center",h.textAlign="left",h.fillText(s.field.value,v+2,x/2));s.select&&(v=s.select.offsetLeft,y=s.select.offsetTop,
B=s.select.offsetWidth,x=s.select.offsetHeight,h.fillStyle="#e0e4e8",h.strokeStyle="#666666",h.lineWidth=1,h.fillRect(v,0,B,x),h.strokeRect(v+0.5,0.5,B,x-1),h.fillStyle="black",h.textAlign="center",h.textAlign="left",h.fillText(s.select.value,v+2,x/2),h.fillStyle="#c0c0c0",h.fillRect(v+B-15+0.5,0.5,15,x-1),h.strokeRect(v+B-15+0.5,0.5,15,x-1),h.fillStyle="black",h.beginPath(),h.moveTo(v+B-15+4.5,x/2-2.5),h.lineTo(v+B-15+8,x/2+2.5),h.lineTo(v+B-15+11.5,x/2-2.5),h.closePath(),h.fill());return u};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g,k,b,c,d,j,f,r,m,l,q,p,t=900;a.Button=function(b,d){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,d);-1===this.font_size&&(this.fontSizeNotSet=!0);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");var c;this.imageSrc.match("_COLORES_")&&(c=this.imageSrc.split("_"),
this.colorInt=new a.Color(c[2]),this.color=new a.Color(c[3]),this.font_size=this.parser.parse(c[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");c=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=c){var f=c.substr(0,c.lastIndexOf(".")),e=c.substr(c.lastIndexOf("."));c.toLowerCase().match(/vacio.gif$/)?(this.imageSrc=this.parser.parse("'vacio.gif'"),this.image.ready=1,3===this.parent.version&&(this.name=this.parser.parse("")),this.emptyImage={ready:!0},this.parser.parse("'vacio.gif'")):
(this.image=this.parent.getImage(c),this.imageOver=this.parent.getImage(f+"_over"+e),this.imageDown=this.parent.getImage(f+"_down"+e))}this.canvas=document.createElement("canvas");this.canvas.setAttribute("class","DescartesButton");this.canvas.setAttribute("id",this.id);this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.ctx=this.canvas.getContext("2d");
this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=!1;this.addControlContainer(this.canvas);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(){g=this.evaluator;k=this.canvas;c=g.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&(this.w=parseInt(c[0][2]),this.h=parseInt(c[0][3]));k.setAttribute("width",this.w+"px");k.setAttribute("height",this.h+"px");k.setAttribute("style",
"left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block;");this.fontSizeNotSet&&(this.font_size=g.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);k.style.display=0<g.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){g=this.evaluator;k=this.canvas;this.activeIfValue=0<g.evalExpression(this.activeif);(this.drawIfValue=0<g.evalExpression(this.drawif))?(k.style.display="block",this.draw()):(this.click=!1,k.style.display=
"none");this.canvas.style.cursor=this.activeIfValue?"pointer":"not-allowed";this.updatePositionAndSize()};a.Button.prototype.draw=function(){g=this.evaluator;b=this.ctx;d=g.evalExpression(this.font_size);j=g.evalExpression(this.name);f=g.evalExpression(this.imageSrc);r="vacio.gif"===f?this.emptyImage:this.parent.getImage(f);b.clearRect(0,0,this.w,this.h);l=m=0;this.click&&(l=m=1);r&&r.ready?r!==this.emptyImage&&r.complete&&b.drawImage(r,parseInt((this.w-r.width)/2)+m,parseInt((this.h-r.height)/2)+
l):(b.fillStyle=this.colorInt.getColor(),b.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(b,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(b,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(b,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),b.fillStyle=this.linearGradient,b.fillRect(0,0,this.w,this.h));this.activeIfValue&&(""!=this.imageOver.src&&this.imageOver.ready&&this.over)&&b.drawImage(this.imageOver,parseInt((this.w-r.width)/2)+m,parseInt((this.h-r.height)/2)+l);this.activeIfValue&&
""!=this.imageDown.src&&this.imageDown.ready&&this.click?b.drawImage(this.imageDown,parseInt((this.w-r.width)/2)+m,parseInt((this.h-r.height)/2)+l):this.click&&!r&&(a.drawLine(b,0,0,0,this.h-2,"gray"),a.drawLine(b,0,0,this.w-1,0,"gray"),b.fillStyle="rgba(0, 0, 0,"+24/255+")",b.fillRect(0,0,this.w,this.h));b.fillStyle=this.color.getColor();b.font=this.italics+" "+this.bold+" "+d+"px Arial";b.textAlign="center";b.textBaseline="middle";this.colorInt.getColor()!=this.color.getColor()&&(b.lineJoin="round",
b.lineWidth=parseInt(d/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(j,e(this.w/2+m)+0.5,e(this.h/2+l)+0.5));b.fillText(j,e(this.w/2+m)+0.5,e(this.h/2+l)+0.5);this.underlined&&(q=b.measureText(j).width,b.strokeStyle=this.color.getColor(),b.lineWidth=e(d/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-q)/2)+m,e((this.h+d)/2)+e(d/5)-1.5+l),b.lineTo(parseInt((this.w+q)/2)+m,e((this.h+d)/2)+e(d/5)-1.5+l),b.stroke());this.activeIfValue||(b.globalCompositeOperation="destination-in",
b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h),b.globalCompositeOperation="source-over")};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,d,c){clearInterval(k);j.click&&(d.call(j),a=c?a:30,k=setTimeout(function(){b(a,d)},a))}function d(f){f.preventDefault();document.activeElement.blur();j.whichButton=a.whichButton(f);"L"==j.whichButton&&j.activeIfValue&&(j.click=!0,j.draw(),j.evaluator.setVariable(j.id,
j.evaluator.evalExpression(j.valueExpr)),"calculate"==j.action&&b(t,j.bottonPressed,!0),p?window.addEventListener("touchend",c):window.addEventListener("mouseup",c))}function c(a){if(j.activeIfValue||j.click)j.click=!1,j.draw(),"calculate"!=j.action&&j.bottonPressed(),a.preventDefault(),p?window.removeEventListener("touchend",c,!1):window.removeEventListener("mouseup",c,!1)}function f(){j.over=!0;j.draw()}function e(){j.over=!1;j.click=!1;j.draw()}p=a.hasTouchSupport;var j=this,k;j.canvas.oncontextmenu=
function(){return!1};this.over=this.click=!1;p?this.canvas.addEventListener("touchstart",d):(this.canvas.addEventListener("mousedown",d),this.canvas.addEventListener("mouseover",f),this.canvas.addEventListener("mouseout",e))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h;a.Spinner=function(b,d){a.Control.call(this,b,d);this.tabindex=++this.parent.tabindex;this.name="["===
this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);
this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var c=this.evaluator.evalExpression(this.incr);0<c?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(c).toString()):this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,
a.Control);a.Spinner.prototype.init=function(){e=this.evaluator;var b=e.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));var d=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var c=2!==this.parent.version?"":"_____",f=a.getTextWidth(d+"_",this.fieldFontSize+"px Arial"),j=2+parseInt(this.h/2),h=parseInt(this.w/2-j/2),c=a.getTextWidth(b+c,this.fieldFontSize+"px Arial");
this.visible||(h=this.w-j,f=0);h<c&&(h=c);""==b&&(h=0);this.w-h-j<f&&(h=this.w-j-f);0>h&&(h=0);b=this.w-(h+j);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.setAttribute("id",this.id);this.canvas.setAttribute("width",j+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style",
"position: absolute; left: "+h+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+j+"px; height : "+this.h/2+"px; left: "+h+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+j+"px; height : "+this.h/2+"px; left: "+h+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",
this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+(b-2)+"px; height : "+(this.h-2)+"px; left: "+(j+h)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=d;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+h+"px; height: "+this.h+"px; line-height: "+this.h+"px;");e.setVariable(this.id,
this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){e=this.evaluator;this.label.innerHTML=e.evalExpression(this.name).toString();0>=e.evalExpression(this.decimals)?(g=e.evalExpression(this.incr),0<g?this.originalIncr=this.incr=e.parser.parse(parseInt(g).toString()):this.incr=e.parser.parse("1")):this.incr=this.originalIncr;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;
this.drawIfValue?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();k=this.field.value;b=this.value;this.value=this.validateValue(e.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value==b&&this.field.value!=k&&(this.value=this.validateValue(k),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.Spinner.prototype.draw=function(){c=this.ctx;
d=this.canvas.width;j=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,d,j);c.fillStyle=this.linearGradient;c.fillRect(0,0,d,j);this.up?(f="gray",r="#f0f8ff"):(f="#f0f8ff",r="gray");a.drawLine(c,0,0,d,0,f);a.drawLine(c,0,0,0,j/2,f);a.drawLine(c,0,j/2,d,j/2,r);this.down?(f="gray",r="#f0f8ff"):(f="#f0f8ff",r="gray");a.drawLine(c,0,j/2+1,d,j/2+1,f);a.drawLine(c,0,j/2+1,0,j,f);a.drawLine(c,0,j-1,d,j-1,r);m=[parseInt(d/2+1),parseInt(d/5+1),parseInt(d-d/5+1)];l=[parseInt(j/8+1),parseInt(j/8+1+j/
4),parseInt(j/8+1+j/4)];c.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";c.beginPath();c.moveTo(m[0],l[0]);c.lineTo(m[1],l[1]);c.lineTo(m[2],l[2]);c.fill();l=[parseInt(j-j/8),parseInt(j-j/8-j/4),parseInt(j-j/8-j/4)];c.fillStyle=this.activeIfValue?"#d00018":"#aa8888";c.beginPath();c.moveTo(m[0],l[0]);c.lineTo(m[1],l[1]);c.lineTo(m[2],l[2]);c.fill();c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,d,j/2);this.down&&c.fillRect(0,j/2,d,j)};a.Spinner.prototype.validateValue=function(a){e=
this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();q=parseFloat(e.evalExpression(e.parser.parse(a.replace(this.parent.decimal_symbol,"."))));isNaN(q)&&(q=0);n=e.evalExpression(this.min);u=e.evalExpression(this.max);""===n&&(n=-Infinity);""===u&&(u=Infinity);q<n&&(q=n);q>u&&(q=u);this.discrete&&(p=e.evalExpression(this.incr),q=0==p?0:p*Math.round(q/p));t=e.evalExpression(this.decimals);0>=t&&(t=0);return q=parseFloat(parseFloat(q).toFixed(t))};
a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.registerMouseAndTouchEvents=
function(){function b(a,d,c){clearInterval(m);if(g.up||g.down)d.call(g),a=c?a:30,m=setTimeout(function(){b(a,d)},a)}function d(c){c.preventDefault();g.whichButton=a.whichButton(c);"L"==g.whichButton&&g.activeIfValue&&(g.up=!0,b(l,g.increase,!0),g.draw())}function c(d){d.preventDefault();g.whichButton=a.whichButton(d);"L"==g.whichButton&&g.activeIfValue&&(g.down=!0,b(l,g.decrease,!0),g.draw())}function f(a){g.up=!1;clearInterval(m);g.draw();a.preventDefault()}function e(a){g.down=!1;clearInterval(m);
g.draw();a.preventDefault()}function j(a){g.up=!1;clearInterval(m);g.draw();a.preventDefault()}function k(a){g.down=!1;clearInterval(m);g.draw();a.preventDefault()}h=a.hasTouchSupport;var g=this,l=h?500:200,m;g.divUp.oncontextmenu=g.divDown.oncontextmenu=g.field.oncontextmenu=g.label.oncontextmenu=function(){return!1};h?this.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):this.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("keydown",
function(a){13==a.keyCode&&g.changeValue(g.field.value)});h?this.divUp.addEventListener("touchstart",d):this.divUp.addEventListener("mousedown",d);h?this.divDown.addEventListener("touchstart",c):this.divDown.addEventListener("mousedown",c);h||this.divUp.addEventListener("mouseout",f);h||this.divDown.addEventListener("mouseout",e);h?(this.divUp.addEventListener("touchend",j),window.addEventListener("touchend",j)):(this.divUp.addEventListener("mouseup",j),window.addEventListener("mouseup",j));h?(this.divDown.addEventListener("touchend",
k),window.addEventListener("touchend",k)):(this.divDown.addEventListener("mouseup",k),window.addEventListener("mouseup",k))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j;a.TextField=function(b,d){a.Control.call(this,b,d);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?
"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var c=this.answerPattern.indexOf("|");this.firstAnswer=-1==c?this.answerPattern:this.answerPattern.substring(0,c)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));
if(this.onlyText){if(!this.valueExprString.match(/^'/)||!this.valueExprString.match(/'$/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){return"''"==a||"'"==a?"":a.match(/^'/)&&a.match(/'$/)?a.substring(1,a.length-1):a};this.formatOutputValue=function(a){return a.toString()}}""==name.trim()&&(name="");this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);
this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){e=this.evaluator;var b=e.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));var d=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var c=a.getTextWidth(d+"_",this.fieldFontSize+"px Arial"),
j=parseInt(this.w/2),k=a.getTextWidth(b,this.fieldFontSize+"px Arial");j<k&&(j=k);""==b&&(j=0);this.w-j<c&&(j=this.w-c);0>j&&(j=0);b=this.w-j;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");
this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(b-2)+"px; height : "+(this.h-2)+"px; left: "+j+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=d;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+j+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+
".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){e=this.evaluator;this.label.innerHTML=e.evalExpression(this.name).toString();this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize();g=this.field.value;k=this.value;this.value=this.validateValue(e.getVariable(this.id));this.field.value=
this.formatOutputValue(this.value);this.value===k&&this.field.value!=g&&(this.value=this.validateValue(g),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";e=this.evaluator;b=parseFloat(e.evalExpression(e.parser.parse(a.toString().replace(this.parent.decimal_symbol,"."))));isNaN(b)&&(b=0);c=e.evalExpression(this.min);""==c&&(c=-Math.Infinity);d=e.evalExpression(this.max);""==d&&(d=Math.Infinity);
this.discrete&&(a=e.evalExpression(this.incr),b=0==a?0:a*Math.round(b/a));return b=parseFloat(parseFloat(b).toFixed(e.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a){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(){j=a.hasTouchSupport;var b=this;b.label.oncontextmenu=function(){return!1};j?b.label.addEventListener("touchstart",
function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(){b.changeValue(b.field.value,!0)});this.field.addEventListener("keydown",function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.abs,g,k,b,c,d,j,f,r,m,l,q;a.Menu=function(b,d){this.options="";a.Control.call(this,b,d);g=this.parser;
k=this.evaluator;this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var c,f=0,e=this.options.length;f<e;f++)c=this.customSplit(this.options[f]),1==c.length?(this.menuOptions.push(c[0]),this.strValue.push(f.toString())):2==c.length&&(this.menuOptions.push(c[0]),""==c[1]?this.strValue.push(f.toString()):
this.strValue.push(c[1]));f=0;for(e=this.menuOptions.length;f<e;f++)this.menuOptions[f]=this.menuOptions[f].match(/^\[/)&&this.menuOptions[f].match(/\]$/)?g.parse(this.menuOptions[f].substring(1,this.menuOptions[f].length-1)):g.parse("'"+this.menuOptions[f]+"'");f=0;for(e=this.strValue.length;f<e;f++)this.strValue[f]=this.strValue[f].match(/^\[/)&&this.strValue[f].match(/\]$/)?g.parse(this.strValue[f].substring(1,this.strValue[f].length-1)):g.parse(this.strValue[f]);this.containerControl=document.createElement("div");
this.label=document.createElement("label");this.select=document.createElement("select");f=0;for(e=this.menuOptions.length;f<e;f++)c=document.createElement("option"),c.innerHTML=k.evalExpression(this.menuOptions[f]),this.select.appendChild(c);this.field=document.createElement("input");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();
this.init()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(){k=this.evaluator;var b=k.evalExpression(this.name).toString();this.label.innerHTML=b;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var d=0,c=0,f=0;this.value=k.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var e=0,j=this.menuOptions.length;e<j;e++)f=a.getTextWidth(k.evalExpression(this.menuOptions[e]).toString(),this.fieldFontSize+"px Arial"),f>d&&(d=f,c=e);d+=25;f=a.getTextWidth(this.formatOutputValue(k.evalExpression(this.strValue[c])),
this.fieldFontSize+"px Arial")+7;c=a.getTextWidth(b,this.fieldFontSize+"px Arial")+10;""==b&&(c=0);this.visible||(f=0);for(b=this.w-f-c;b<d&&0<c;)c--,b++;for(;b<d&&0<f;)f--,b++;for(;c+b+f+1<this.w;)b++,f++;d=c;e=d+b;f=this.w-e;j=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: "+c+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"menu");this.field.value=j;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(f-2)+"px; height : "+(this.h-2)+"px; left: "+e+"px;");this.select.setAttribute("id",
this.id+"menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align: left; font-size: "+this.fieldFontSize+"px; line-height: "+this.h+"px; width : "+b+"px; height : "+this.h+"px; left: "+d+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.selectedIndex=this.indexValue;k.setVariable(this.id,parseFloat(j));this.update()};a.Menu.prototype.update=function(){k=this.evaluator;this.label.innerHTML=
k.evalExpression(this.name).toString();for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=k.evalExpression(this.menuOptions[a]);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);isNaN(this.value)&&(this.value=0);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.customSplit=function(a){f=!1;r="";m=0;for(l=-1;m<a.length;){q=a.charAt(m);a.charAt(m-1);if("["===q&&-1===l){if(f||""!=r)r+="\u00a6";l++}else"["===q?l++:"]"===q&&0===l?(f=!0,l--):"]"==a.charAt(m)&&(l=0>l?l:l-1);r+=a.charAt(m);m++}return r.split("\u00a6")};a.Menu.prototype.getIndex=
function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));b=-1;c=Infinity;for(var f=0,j=this.strValue.length;f<j;f++)d=e(a-parseFloat(this.evaluator.evalExpression(this.strValue[f]))),d<=c&&(c=d,b=f);return b};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){j=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=
function(){return!1};j?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){b.value=b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=
b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g="h",k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s,v,y,B,x,D;a.Scrollbar=function(b,d){a.Control.call(this,b,d);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-
1)):this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?g:"v";this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);
this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){k=this.evaluator;this.findOffset();this.incr=0==k.evalExpression(this.decimals)?1:(k.evalExpression(this.max)-k.evalExpression(this.min))/100;this.value=this.validateValue(k.evalExpression(this.valueExpr));
c=this.formatOutputValue(this.value);d=this.evaluator.evalExpression(this.expresion);this.x=d[0][0];this.y=d[0][1];4==d[0].length&&(this.w=d[0][2],this.h=d[0][3]);this.orientation=this.w>=this.h?g:"v";this.initScroll(c);this.changeScrollPositionFromValue();this.prePos=this.pos;k.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(d){b=this;k=b.evaluator;var c=k.evalExpression(b.name).toString();b.label.innerHTML=c;var f="v"===b.orientation?parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize=
"v"===b.orientation?f-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(f):10;var e=a.getTextWidth(d+"_",b.fieldFontSize+"px Arial"),j=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==c?0:f;b.fieldHeight=""==b.visible?0:f;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=b.h-b.labelHeight-b.fieldHeight,18<=b.canvasHeight+b.y-j&&(b.canvasHeight=j),c=0,c=b.fieldHeight,e=c+b.canvasHeight,b.canvasX=0,b.canvasY=b.fieldHeight,b.labelWidth=b.w,b.labelY=e,b.upWidth=b.downW=b.w,b.upHeight=
b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=e-b.downH,b.fieldWidth=b.w,b.fieldX=0,b.scrollManipulatorW=b.w,b.scrollManipulatorH=parseInt((b.canvasHeight-b.upHeight-b.downH-b.labelHeight-b.fieldHeight)/10),b.scrollManipulatorH=15>b.scrollManipulatorH?15:b.scrollManipulatorH,b.scrollManipulatorLimInf=e-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=c+b.downH;else{f=a.getTextWidth(c,b.fieldFontSize+"px Arial")+10;b.labelWidth=f;b.fieldWidth=e;""==c&&(b.labelWidth=0);b.visible||(b.fieldWidth=
0);for(e=b.w-b.fieldWidth-b.labelWidth;58>e&&0<b.labelWidth;)b.labelWidth--,e++;for(;58>e&&0<b.fieldWidth;)b.fieldWidth--,e++;c=b.labelWidth;f=c+e;b.fieldWidth=b.w-f;b.canvasWidth=e;b.canvasHeight=b.h;b.canvasX=b.labelWidth;b.canvasY=0;b.fieldX=b.canvasWidth+b.labelWidth;b.labelHeight=b.h;b.labelY=0;b.upWidth=b.downW=15;b.upHeight=b.downH=b.h;b.upX=f-b.downW;b.upY=0;b.downX=b.labelWidth;b.downY=0;b.scrollManipulatorW=parseInt((b.canvasWidth-b.upWidth-b.downW)/10);b.scrollManipulatorW=15>b.scrollManipulatorW?
15:b.scrollManipulatorW;b.scrollManipulatorH=b.h;b.scrollManipulatorLimInf=c+b.downW;b.scrollManipulatorLimSup=c+b.canvasWidth-b.downW-b.scrollManipulatorW}b.containerControl.setAttribute("class","DescartesScrollbarContainer");b.containerControl.setAttribute("style","width: "+b.w+"px; height: "+b.h+"px; left: "+b.x+"px; top: "+b.y+"px; z-index: "+b.zIndex+";");b.canvas.setAttribute("width",b.w+"px");b.canvas.setAttribute("height",b.h+"px");b.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");
b.ctx=b.canvas.getContext("2d");b.divUp.setAttribute("class","DescartesCatcher");b.divUp.setAttribute("style","width : "+b.upWidth+"px; height : "+b.upHeight+"px; left: "+b.upX+"px; top: "+b.upY+"px;");b.divDown.setAttribute("class","DescartesCatcher");b.divDown.setAttribute("style","width : "+b.downW+"px; height : "+b.downH+"px; left: "+b.downX+"px; top: "+b.downY+"px;");b.scrollManipulator.setAttribute("class","DescartesCatcher");b.scrollManipulator.setAttribute("style","width : "+b.scrollManipulatorW+
"px; height : "+b.scrollManipulatorH+"px;");b.scrollManipulator.style.top=("v"===b.orientation?b.scrollManipulatorLimInf:0)+"px";b.scrollManipulator.style.left=("v"===b.orientation?0:b.scrollManipulatorLimInf)+"px";b.field.setAttribute("type","text");b.field.setAttribute("id",b.id+"scrollbar");b.field.setAttribute("class","DescartesScrollbarField");b.field.setAttribute("style","font-size: "+b.fieldFontSize+"px; width : "+(b.fieldWidth-2)+"px; height : "+(b.fieldHeight-2)+"px; left: "+b.fieldX+"px; top: 0px;");
b.field.value=d;0===b.fieldHeight&&(b.field.style.display="none");b.label.setAttribute("class","DescartesScrollbarLabel");b.label.setAttribute("style","font-size:"+b.fieldFontSize+"px; width: "+b.labelWidth+"px; height: "+b.labelHeight+"px; line-height: "+b.labelHeight+"px; left: 0px; top:"+b.labelY+"px;")};a.Scrollbar.prototype.update=function(){k=this.evaluator;this.label.innerHTML=k.evalExpression(this.name).toString();this.incr=0==k.evalExpression(this.decimals)?1:(k.evalExpression(this.max)-
k.evalExpression(this.min))/100;this.activeIfValue=0<k.evalExpression(this.activeif);this.drawIfValue=0<k.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();var a=this.validateValue(k.getVariable(this.id));a!=this.value&&!(0<Math.abs(a-this.value)&&1E-9>Math.abs(a-this.value))&&(this.value=a,this.changeScrollPositionFromValue(),this.prePos=
this.pos);this.value=a;this.field.value=this.formatOutputValue(this.value);k.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){b=this;j=b.ctx;r=e(this.w);f=e(this.h);j.fillStyle="#e0e4e8";j.fillRect(0,0,r,f);j.strokeStyle="#7a8a99";b.down&&(j.fillStyle="#ccdcec",j.fillRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1));j.strokeRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1);b.up&&(j.fillStyle="#ccdcec",j.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));j.strokeRect(b.upX+0.5,
b.upY-0.5,b.upWidth,b.upHeight+1);m=4;j.fillStyle="black";j.beginPath();b.orientation===g?(j.moveTo(b.downX+m,b.downH/2),j.lineTo(b.downX+b.downW-m,m),j.lineTo(b.downX+b.downW-m,b.downH-m),j.moveTo(b.upX+b.upWidth-m,b.downH/2),j.lineTo(b.upX+m,m),j.lineTo(b.upX+m,b.downH-m),j.fill(),b.activeIfValue&&(l=e(b.pos),j.fillStyle="#ccdcec",j.fillRect(l+0.5,0,e(b.scrollManipulatorW),f),j.strokeStyle="#6382bf",j.strokeRect(l+0.5,0,e(b.scrollManipulatorW),f),q=e(b.scrollManipulatorW/2),j.beginPath(),j.moveTo(l+
q+0.5-2,3),j.lineTo(l+q+0.5-2,f-3),j.moveTo(l+q+0.5,3),j.lineTo(l+q+0.5,f-3),j.moveTo(l+q+0.5+2,3),j.lineTo(l+q+0.5+2,f-3),j.stroke())):(j.moveTo(b.downX+b.downW/2,b.downY+b.downH-m),j.lineTo(b.downX+m,b.downY+m),j.lineTo(b.downX+b.downW-m,b.downY+m),j.moveTo(b.upX+b.upWidth/2,b.upY+m),j.lineTo(b.upX+m,b.upY+b.upHeight-m),j.lineTo(b.upX+b.upWidth-m,b.upY+b.upHeight-m),j.fill(),b.activeIfValue&&(l=e(b.pos),j.fillStyle="#ccdcec",j.fillRect(0,l+0.5,r,e(b.scrollManipulatorH)),j.strokeStyle="#6382bf",
j.strokeRect(0,l+0.5,r,e(b.scrollManipulatorH)),q=e(b.scrollManipulatorH/2),j.beginPath(),j.moveTo(3,l+q+0.5-2),j.lineTo(r-3,l+q+0.5-2),j.moveTo(3,l+q+0.5),j.lineTo(r-3,l+q+0.5),j.moveTo(3,l+q+0.5+2),j.lineTo(r-3,l+q+0.5+2),j.stroke()));j.strokeRect(0.5,0.5,r-1,f-1);b.activeIfValue||(j.fillStyle="rgba(240,240,240,"+160/255+")",j.fillRect(0,0,r,f.h))};a.Scrollbar.prototype.validateValue=function(a){k=this.evaluator;p=a.toString();p=parseFloat(p.replace(this.parent.decimal_symbol,"."));isNaN(p)&&(p=
0);this.minimo=k.evalExpression(this.min);p<this.minimo&&(this.value=null,p=this.minimo);this.maximo=k.evalExpression(this.max);p>this.maximo&&(this.value=null,p=this.maximo);t=this.incr;p=0!=t?p*t/t:0;this.fixed&&(p=parseFloat(parseFloat(p).toFixed(k.evalExpression(this.decimals))));return p};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==g?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==g?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&&(n=this.validateValue(a),n!=this.value&&(this.value=n,this.field.value=this.formatOutputValue(n),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){k=this.evaluator;u=this.scrollManipulatorLimInf;h=this.scrollManipulatorLimSup;s=k.evalExpression(this.min);
v=k.evalExpression(this.max);t=this.incr;n=e((this.pos-u)*(v-s)/(h-u)/t)*t+s;n!=this.value&&(this.value=n,this.field.value=this.formatOutputValue(n),k.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){k=this.evaluator;u=this.scrollManipulatorLimInf;h=this.scrollManipulatorLimSup;s=k.evalExpression(this.min);v=k.evalExpression(this.max);t=this.incr;this.pos=(this.value-s)*(h-u)/
(v-s)+u;this.orientation==g?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function b(a,d,c,f){clearInterval(u);if((s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-f))d.call(s),a=c?a:30,u=setTimeout(function(){b(a,d,!1,f)},a)}function d(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(c),s.canvasClick=!0,s.orientation==
g?s.clickPos.x<s.prePos?b(v,s.decrease10,!0,s.minimo):b(v,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?b(v,s.increase10,!0,s.maximo):b(v,s.decrease10,!0,s.minimo))}function c(a){s.canvasClick=!1;clearInterval(u);a.preventDefault()}function f(a){!0==s.canvasClick&&(s.clickPos=s.getCursorPosition(a),a.preventDefault())}function e(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("mouseup",h),window.addEventListener("mousemove",l),a.preventDefault())}function j(a){s.activeIfValue&&
(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("touchend",k),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function h(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("mouseup",h,!1);window.removeEventListener("mousemove",l,!1);a.preventDefault()}function k(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("touchend",k,!1);window.removeEventListener("touchmove",l,!1);a.preventDefault()}function l(a){var b=
s.getCursorPosition(a);s.orientation==g?(s.pos=s.prePos-(s.initPos.x-b.x),s.pos<s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos>s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.scrollManipulatorW+"px; height : "+s.h+"px; left: "+s.pos+"px; top: 0px;")):(s.pos=s.prePos-(s.initPos.y-b.y),s.pos>s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),
s.pos<s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.w+"px; height : "+s.scrollManipulatorH+"px; left: 0px; top: "+s.pos+"px;"));s.changeValueForScrollMovement();a.preventDefault()}function m(d){d.preventDefault();s.whichButton=a.whichButton(d);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(v,s.increase,!0,s.maximo))}function n(d){d.preventDefault();s.whichButton=
a.whichButton(d);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(v,s.decrease,!0,s.minimo))}function p(a){s.up=!1;clearInterval(u);a.preventDefault()}function r(a){s.down=!1;clearInterval(u);a.preventDefault()}function q(a){s.up=!1;clearInterval(u);a.preventDefault();s.draw()}function t(a){s.down=!1;clearInterval(u);a.preventDefault();s.draw()}y=a.hasTouchSupport;var s=this,v=y?500:200,u;s.canvas.oncontextmenu=s.divUp.oncontextmenu=s.divDown.oncontextmenu=s.label.oncontextmenu=s.field.oncontextmenu=
s.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&s.changeValue(s.field.value)});y?this.canvas.addEventListener("touchstart",d):this.canvas.addEventListener("mousedown",d);y||this.divDown.addEventListener("mouseout",r);y?window.addEventListener("touchend",c):window.addEventListener("mouseup",c);y?this.canvas.addEventListener("touchmove",f):this.canvas.addEventListener("mousemove",f);y?this.scrollManipulator.addEventListener("touchstart",
j):this.scrollManipulator.addEventListener("mousedown",e);y?this.divUp.addEventListener("touchstart",m):this.divUp.addEventListener("mousedown",m);y?this.divDown.addEventListener("touchstart",n):this.divDown.addEventListener("mousedown",n);y||this.divUp.addEventListener("mouseout",p);y||this.divDown.addEventListener("mouseout",r);y?window.addEventListener("touchend",q):window.addEventListener("mouseup",q);y?window.addEventListener("touchend",t):window.addEventListener("mouseup",t)};a.Scrollbar.prototype.findOffset=
function(){B=this.containerControl;this.offsetTop=this.offsetLeft=0;x=this.containerControl.style.display;for(this.containerControl.style.display="block";B;)this.offsetLeft+=B.offsetLeft||0,this.offsetTop+=B.offsetTop||0,B=B.parentNode;this.containerControl.style.display=x};a.Scrollbar.prototype.getCursorPosition=function(b){D=a.getCursorPosition(b);return{x:D.x-this.offsetLeft,y:D.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Audio=function(e,
b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,e,b);var c=this,d=c.evaluator.evalExpression(c.expresion);4==d[0].length?(c.w=d[0][2],c.h=d[0][3]):(c.w=200,c.h=28);c.audio=c.parent.getAudio(c.file);c.autoplay&&(c.audio.setAttribute("autoplay","autoplay"),c.audio.play());c.loop&&c.audio.setAttribute("loop","loop");c.controls&&c.audio.setAttribute("controls","controls");c.audio.setAttribute("style","position: absolute; width: "+c.w+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+
c.zIndex+";");c.addControlContainer(c.audio);c.evaluator.setFunction(c.id+".play",function(){c.audio.play()});c.evaluator.setFunction(c.id+".pause",function(){c.audio.pause()});c.evaluator.setFunction(c.id+".stop",function(){c.audio.pause();c.audio.currentTime=0});c.audio.addEventListener("timeupdate",function(){c.evaluator.setVariable(c.id+".currentTime",c.audio.currentTime)})};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";this.audio.style.top=this.y+
"px";this.update()};var g;a.Audio.prototype.update=function(){e=this.evaluator;(g=0<e.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",g!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=g;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Video=function(k,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,k,b);var c=this;e=c.evaluator;var d=c.evaluator.evalExpression(c.expresion);
4==d[0].length?(c.w=d[0][2],c.h=d[0][3]):(c.w=null,c.h=null);c.video=document.createElement("video");c.autoplay&&c.video.setAttribute("autoplay","autoplay");c.loop&&c.video.setAttribute("loop","loop");c.controls&&c.video.setAttribute("controls","controls");c.poster&&c.video.setAttribute("poster",c.poster);c.w&&(c.video.setAttribute("width",c.w),c.video.setAttribute("height",c.h));c.video.setAttribute("style","position: absolute; overflow: hidden; left: "+c.x+"px; top: "+c.y+"px;");var d=c.file,j=
d.lastIndexOf(".");-1!=j&&(d=c.file.substring(0,j));c.video.canPlayType("video/mp4")&&(j=document.createElement("source"),j.setAttribute("src",d+".mp4"),j.setAttribute("type","video/mp4"),c.video.appendChild(j));c.video.canPlayType("video/ogg")&&(j=document.createElement("source"),j.setAttribute("src",d+".ogg"),j.setAttribute("type","video/ogg"),c.video.appendChild(j),j=document.createElement("source"),j.setAttribute("src",d+".ogv"),j.setAttribute("type","video/ogg"),c.video.appendChild(j));c.video.canPlayType("video/webm")&&
(j=document.createElement("source"),j.setAttribute("src",d+".webm"),j.setAttribute("type","video/webm"),c.video.appendChild(j));c.addControlContainer(c.video);c.evaluator.setFunction(c.id+".play",function(){c.video.play()});c.evaluator.setFunction(c.id+".pause",function(){c.video.pause()});c.evaluator.setFunction(c.id+".stop",function(){c.video.pause();c.video.currentTime=0});c.video.addEventListener("timeupdate",function(){c.evaluator.setVariable(c.id+".currentTime",c.video.currentTime)})};a.extend(a.Video,
a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};var g;a.Video.prototype.update=function(){e=this.evaluator;g=0<e.evalExpression(this.drawif);0<e.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",g!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=g;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g;a.TextArea=function(e,
b){this.font="Monospaced,PLAIN,12";a.Control.call(this,e,b);this.region="interior";this.tabindex=++this.parent.tabindex;if(this.answer){this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var c=this.parent.lessonParser.parseText(this.answer)}this.containerControl=document.createElement("div");this.textArea=document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");
this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?this.rawText:this.text.toHTML();c&&"simpleText"!=c.type&&(this.answer=this.text.hasFormula?"":c.toHTML());this.evaluator.setVariable(this.id,
this.text);this.drawButton();this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){g=this.answer?28:8;e=this.evaluator;var k;k=this.text.match(/<span/)?this.text:this.text.replace(/\\n/g,"<br/>");this.containerControl.setAttribute("class","DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=
0<e.evalExpression(this.drawif)?"block":"none";this.containerControl.setAttribute("spellcheck","false");this.textArea.setAttribute("class","DescartesTextAreaContainer");this.textArea.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-g)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable","true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+
k+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-g)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textAreaAnswer.style.display=this.showAnswer?"block":"none";this.textAreaAnswer.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;'>"+this.answer+"</span>";this.showButton.setAttribute("style",
"width: 20px; height: 16px; position: absolute; bottom: 4px; right: 4px; cursor: pointer;");this.showButton.style.backgroundImage="url("+this.imageUnPush+")";this.showButton.style.display=this.answer?"block":"none";this.showButton.innerHTML="<span style='position: relative; top: 2px; text-align: center; font: 9px Arial'> S </span>";this.activeCover.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.update()};a.TextArea.prototype.drawButton=
function(){var e=document.createElement("canvas");e.setAttribute("width",20);e.setAttribute("height",16);var b=e.getContext("2d");this.canvas=e;this.ctx=b;this.createGradient(20,16);b.lineWidth=1;b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(b,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(b,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=e.toDataURL();b.fillStyle="white";b.fillRect(0,
0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,0,0,0,14,"gray");a.drawLine(b,0,0,19,0,"gray");b.fillStyle="rgba(0, 0, 0,"+24/255+")";b.fillRect(0,0,this.w,this.h);this.imagePush=e.toDataURL()};a.TextArea.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);var a;a=this.text.match(/<span/)?this.rawText:this.text;e.setVariable(this.id,a);this.activeCover.style.display=this.activeIfValue?
"none":"block";this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize()};a.TextArea.prototype.registerMouseAndTouchEvents=function(){function a(c){c.preventDefault();b.showButton.style.backgroundImage="url("+b.imageUnPush+")"}var b=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();b.showAnswer=!b.showAnswer;b.textAreaAnswer.style.display=b.showAnswer?"block":"none";b.showButton.childNodes[0].childNodes[0].textContent=b.showAnswer?
"T":"S";b.showButton.style.backgroundImage="url("+b.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var b=a.getContext("2d");b.fillStyle="white";b.strokeStyle="black";b.lineWidth=1;b.fillRect(0,0,this.w,this.h);b.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e=2*Math.PI,g,k,b,c,d,j,f,r,m;a.GraphicControl=function(b,d){k=b.evaluator.parser;this.text=this.spaceID="";this.size=k.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,d);this.touchId=null;this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=k.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=k.parse(this.constraintExpr.substring(1,
this.constraintExpr.length-1))),"compOperator"==this.constraint.type?this.newt=new a.R2Newton(this.evaluator,this.constraint):this.constraint=null,r=new a.R2(0,0));this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);
this.registerMouseAndTouchEvents();this.xString=this.id+".x";this.yString=this.id+".y";this.activoString=this.id+".activo";""!==this.space.id&&2!==b.version?(this.mxString=this.space.id+".mouse_x",this.myString=this.space.id+".mouse_y",this.mclickedString=this.space.id+".mouse_clicked",this.mclicizquierdoString=this.space.id+".clic_izquierdo"):(this.mxString="mouse_x",this.myString="mouse_y",this.mclickedString="mouse_clicked",this.mclicizquierdoString="clic_izquierdo");this.init()};a.extend(a.GraphicControl,
a.Control);a.GraphicControl.prototype.init=function(){g=this.evaluator;m=a.hasTouchSupport;var b=g.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];g.setVariable(this.xString,this.x);g.setVariable(this.yString,this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height):(this.width=2*g.evalExpression(this.size),this.height=2*g.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";g.setVariable(this.activoString,0);this.update()};a.GraphicControl.prototype.update=function(){g=
this.evaluator;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.evalExpression(this.drawif);this.x=g.getVariable(this.xString);this.y=g.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=!this.activeIfValue?"none":"block";this.mouseCacher.style.left=parseInt(b-this._w/2)+"px";this.mouseCacher.style.top=parseInt(c-this._h/2)+"px";this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=
function(){g=this.evaluator;this.drawIfValue&&(j=this.ctx,f=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+0.5,c=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,c),this.image.ready?(this.image.complete&&j.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(c-this.image.height/2)),this.trace&&(f.save(),f.translate(b,c),f.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),f.beginPath(),f.arc(0,0,1,0,e,!1),f.restore(),f.lineWidth=
1,f.strokeStyle=this.trace.getColor(),f.stroke())):(j.beginPath(),j.arc(b,c,parseInt(this.width/2),0,e,!1),j.fillStyle=this.colorInt.getColor(),j.fill(),j.lineWidth=1,j.strokeStyle=this.color.getColor(),j.stroke(),this.active&&(j.beginPath(),j.arc(b,c,parseInt(this.width/2)-2,0,e,!1),j.strokeStyle=this.colorInt.borderColor(),j.stroke()),this.trace&&(f.lineWidth=1,f.strokeStyle=this.trace.getColor(),f.beginPath(),f.arc(b,c,parseInt(this.width/2),0,e,!1),f.stroke())))};a.GraphicControl.prototype.evalConstraint=
function(){r.set(this.x,this.y);d=this.newt.findZero(r);this.x=d.x;this.y=d.y;this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y)};a.GraphicControl.prototype.drawText=function(a,b){j=this.ctx;g=this.evaluator;j.fillStyle=this.color.getColor();j.font=this.font;j.textBaseline="alphabetic";j.fillText(g.evalExpression(this.text[0],g.evalExpression(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=
function(){for(var a=this.parent.spaces,b,d=0,c=a.length;d<c;d++)if(b=a[d],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.activoString,0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(d){d.preventDefault();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.activoString,1),h.evaluator.setVariable(h.mclickedString,0),h.evaluator.setVariable(h.mclicizquierdoString,0),h.posAnte=h.getCursorPosition(d),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)),h.evaluator.setVariable(h.myString,h.space.getRelativeY(h.posAnte.y)),h.parent.update(),
window.addEventListener("mouseup",c),window.addEventListener("mousemove",f))}function d(a){a.preventDefault();h.activeIfValue&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.activoString,1),h.evaluator.setVariable(h.mclickedString,0),h.evaluator.setVariable(h.mclicizquierdoString,0),h.posAnte=h.getCursorPosition(a),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)),h.evaluator.setVariable(h.myString,
h.space.getRelativeY(h.posAnte.y)),h.parent.update(),window.addEventListener("touchmove",f),window.addEventListener("touchend",c))}function c(b){b.preventDefault();h.touchId=null;h.evaluator.setVariable(h.mclickedString,1);h.evaluator.setVariable(h.mclicizquierdoString,1);if(h.activeIfValue||h.active)h.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",f,!1),window.removeEventListener("touchend",c,!1)):(window.removeEventListener("mouseup",c,!1),window.removeEventListener("mousemove",
f,!1)),h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)+h.x),h.evaluator.setVariable(h.myString,h.space.getRelativeY(h.posAnte.y)+h.y),h.parent.update(),h.mouseCacher.style.left=h.space.getAbsoluteX(h.x)-h._w/2+"px",h.mouseCacher.style.top=h.space.getAbsoluteY(h.y)-h._h/2+"px"}function f(a){a.preventDefault();a.touchId=h.touchId;h.evaluator.setVariable(h.mclickedString,0);h.evaluator.setVariable(h.mclicizquierdoString,0);k=h.getCursorPosition(a);h.posX=h.prePos.x-(h.posAnte.x-
k.x);h.posY=h.prePos.y-(h.posAnte.y-k.y);h.evaluator.setVariable(h.xString,h.space.getRelativeX(h.posX));h.evaluator.setVariable(h.yString,h.space.getRelativeY(h.posY));h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)+h.space.getRelativeX(h.posX));h.evaluator.setVariable(h.myString,h.space.getRelativeY(h.posAnte.y)+h.space.getRelativeY(h.posY));h.parent.updateControls();h.parent.update()}function e(){h.over=!0}function j(){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",b),this.mouseCacher.addEventListener("mouseover",e),this.mouseCacher.addEventListener("mouseout",j));var k};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId){d=0;for(c=a.touches.length;d<c;d++)if(a.touches[d].identifier==a.touchId){b=a.touches[d];break}}else for(var d=0,c=a.touches.length;d<
c;d++)if(a.target==a.touches[d].target){b=a.touches[d];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};
return a}(descartesJS||{}),descartesJS=function(a,e){var g,k,b,c,d,j,f,r,m,l;if(a.loadLib)return a;var q,p,t,n,u,h,s,v,y=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,B,x,D,C,A,z,G,F,H,J,w,I,E,O,P,L,Q,R,M,N,K;a.LessonParser=function(b){this.parent=b;this.parser=b.evaluator.parser;this.RTFparser=new a.RTFParser(b.evaluator)};a.LessonParser.prototype.parseButtonsConfig=function(a){var b={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var d=0,c=a.length;d<
c;d++)switch(t=a[d][0],n=a[d][1],p=e[t],p){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[p]=parseInt(n);break;case "about":case "config":case "init":case "clear":b[p]="true"===e[n];break;default:console.log("----- attributo de space no identificado: <"+t+"> valor: <"+n+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){u={};b=this.split(b);for(var d=0,c=b.length;d<c;d++)switch(t=b[d][0],n=b[d][1],p=e[t],p){case "type":case "id":case "cID":case "file":u[p]=
n;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":u[p]="true"===e[n];break;case "bg_display":case "render":u[p]=e[n];break;case "net":case "net10":case "axes":case "text":u[p]="false"===e[n]?"":new a.Color(n,this.parent.evaluator);break;case "x_axis":case "y_axis":u[p]="false"===e[n]?"":n;break;case "O.x":u.OxExpr=n;break;case "O.y":u.OyExpr=n;break;case "image":u.imageSrc=n;break;case "x":q=n;q="%"===q[q.length-1]?(this.parent.container.width*parseFloat(q)/
100).toString():n;u.xExpr=this.parser.parse(q);break;case "y":q=n;q="%"===q[q.length-1]?(this.parent.container.height*parseFloat(q)/100).toString():n;u.yExpr=this.parser.parse(q);break;case "width":q=n;"%"===q[q.length-1]?(u.wExpr=q,q=this.parent.container.width*parseFloat(q)/100):(q=parseFloat(n),q!=n&&(q=this.parent.container.width));u.w=q;break;case "height":q=n;"%"===q[q.length-1]?(u.hExpr=q,q=this.parent.container.height*parseFloat(q)/100):(q=parseFloat(n),q!=n&&(q=this.parent.container.height));
u.h=q;break;case "drawif":u.drawif=this.parser.parse(n);break;case "scale":q=parseFloat(n);q.toString()!=n&&(q=48);u.scale=q;break;case "background":u.background=new a.Color(n,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+t+"> valor: <"+n+"> -----")}switch(u.type){case "R2":return new a.Space2D(this.parent,u);case "R3":return new a.Space3D(this.parent,u);case "AP":return new a.SpaceAP(this.parent,u);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,
u);default:return new a.Space2D(this.parent,u)}};a.LessonParser.prototype.parseControl=function(b){h={type:"numeric"};b=this.split(b);for(var d=0,c=b.length;d<c;d++)switch(t=b[d][0],n=b[d][1],p=e[t],p){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":h[p]=n;break;case "gui":case "region":case "action":case "msg_pos":case "poster":h[p]=e[n];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":h[p]=
"true"===e[n];break;case "color":case "colorInt":case "trace":h[p]=new a.Color(n,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":h[p]=this.parser.parse(n);break;case "constraint":h.constraintExpr=n;break;case "image":h.imageSrc=n;break;case "space":h.spaceID=n;break;case "type":h.type=e[n.trim()];break;case "expresion":h.expresion=this.parser.parse(n.replace(")(",","));break;case "bold":"false"!=e[n]&&(h.bold="bold");break;
case "italics":"false"!=e[n]&&(h.italics="italic");break;case "underlined":"false"!=e[n]&&(h.underlined=!0);break;case "value":var f=n.replace(/&squot;/g,"'");f.match(/^\|/)&&(f="'"+f.substring(1),f.match(/\|$/)&&(f=f.substring(0,f.length-1)+"'"));h.valueExpr=this.parser.parse(f);h.valueExprString=f;break;case "incr":0!=n&&(h.incr=this.parser.parse(n));break;case "exponentialif":h.exponentialif=parseFloat(n);break;case "text":h.rawText=n;for(var f=this.parseText(n),j=0,k=f.length;j<k;j++)f[j]=this.parser.parse(f[j],
!1);h.text=f;break;default:j=t.indexOf(".");f=e[t.substring(0,j)];j=e[t.substring(j+1)];if("parameter"===f&&"font"===j){h.parameterFont=n;break}else if("Explanation"===f&&"font"===j){h.ExplanationFont=n;break}else if("tooltip"===f&&"font"===j){h.tooltipFont=n;break}console.log("----- attributo de control no identificado: <"+t+"> valor: <"+n+"> -----")}if("numeric"===h.type)switch(h.gui){case "spinner":return new a.Spinner(this.parent,h);case "button":return new a.Button(this.parent,h);case "textfield":return new a.TextField(this.parent,
h);case "menu":return new a.Menu(this.parent,h);case "scrollbar":return new a.Scrollbar(this.parent,h);default:return new a.Spinner(this.parent,h)}else{if("video"===h.type)return new a.Video(this.parent,h);if("audio"===h.type)return new a.Audio(this.parent,h);if("graphic"===h.type)return new a.GraphicControl(this.parent,h);if("text"===h.type)return new a.TextArea(this.parent,h)}};a.LessonParser.prototype.parseGraphic=function(b,d,c,f){s={rotateExp:f,parameter:"t"};b=this.split(b);f=0;for(var j=b.length;f<
j;f++)switch(t=b[f][0],n=b[f][1],p=e[t],p){case "type":case "align":s[p]=e[n];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":s[p]="true"===e[n];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":s[p]="false"===e[n]?"":new a.Color(n,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":s[p]=n;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "init":case "end":case "opacity":case "inirot":case "inipos":case "range":s[p]=
this.parser.parse(n);break;case "space":s.spaceID=n;break;case "expresion":"macro"!=s.type?(s.expresion=this.parser.parse(n),s.expresionString=n):s.expresion=n;break;case "text":s.text=this.parseText(n);break;case "file":var h=n.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(y)&&(h="'"+h+"'");s.file=this.parser.parse(h);break;case "border":"false"!=e[n]&&(s.border=new a.Color(n,this.parent.evaluator));break;default:if(void 0!=s.family&&
t.substring(0,s.family.length+1)===s.family+"."){switch(e[t.substring(s.family.length+1)]){case "interval":s.family_interval=this.parser.parse(n);break;case "steps":s.family_steps=this.parser.parse(n)}break}if(void 0!=s.parameter&&t.match(s.parameter+".")){s.parameter!==t.substring(0,t.indexOf(s.parameter)+s.parameter.length)&&(s.parameter=t.substring(0,t.indexOf(s.parameter)+s.parameter.length));switch(e[t.substring(s.parameter.length+1)]){case "interval":s.parameter_interval=this.parser.parse(n);
break;case "steps":s.parameter_steps=this.parser.parse(n)}break}console.log("----- attributo del graphic no identificado: <"+t+"> valor: <"+n+"> -----")}d&&(s.abs_coord=d);c&&(s.background=c);switch(s.type){case "text":return new a.Text(this.parent,s);case "image":return new a.Image(this.parent,s);case "point":return new a.Point(this.parent,s);case "polygon":return new a.Polygon(this.parent,s);case "arc":return new a.Arc(this.parent,s);case "segment":return new a.Segment(this.parent,s);case "arrow":return new a.Arrow(this.parent,
s);case "macro":return new a.Macro(this.parent,s);case "curve":return new a.Curve(this.parent,s);case "equation":return new a.Equation(this.parent,s);case "sequence":return new a.Sequence(this.parent,s);case "fill":return new a.Fill(this.parent,s)}};a.LessonParser.prototype.parse3DGraphic=function(b,d,c,f){s={rotateExp:f,parameter:"t"};b=this.split(b);d=0;for(c=b.length;d<c;d++)switch(t=b[d][0],n=b[d][1],p=e[t],p){case "type":case "model":s[p]=e[n];break;case "background":case "fixed":case "edges":s[p]=
"true"===e[n];break;case "color":case "backcolor":s[p]=new a.Color(n,this.parent.evaluator);break;case "type":case "model":s[p]=e[n];break;case "background":case "fixed":case "edges":case "split":s[p]="true"===e[n];break;case "color":case "backcolor":s[p]=new a.Color(n,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":s[p]=this.parser.parse(n);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":s[p]=
n;break;case "space":s.spaceID=n;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(n),s.expresionString=n):s.expresion=n.replace(/\\n/g,"");break;case "text":f=this.parseText(n);for(var j=0,h=f.length;j<h;j++)f[j]=this.parser.parse(f[j],!1);s.text=f;break;case "file":f=n.replace(/&squot;/g,"'");"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f.match(/./)&&(f="'"+f+"'");s.file=this.parser.parse(f);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":s[p]=
this.parser.parse(n);break;case "family":case "parameter":case "font":case "name":s[p]=n;break;case "space":s.spaceID=n;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(n),s.expresionString=n):s.expresion=n;break;case "text":f=this.parseText(n);j=0;for(h=f.length;j<h;j++)f[j]=this.parser.parse(f[j],!1);s.text=f;break;case "file":f=n.replace(/&squot;/g,"'");"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f.match(/./)&&
(f="'"+f+"'");s.file=this.parser.parse(f);break;default:if(void 0!==s.family&&t.substring(0,s.family.length+1)===s.family+"."){"interval"===e[t.substring(s.family.length+1)]?s.family_interval=this.parser.parse(n):s.family_steps=this.parser.parse(n);break}console.log("----- attributo del graphic3D no identificado: <"+t+"> valor: <"+n+"> -----")}switch(s.type){case "point":return new a.Point3D(this.parent,s);case "segment":return new a.Segment3D(this.parent,s);case "polygon":return new a.Polygon3D(this.parent,
s);case "curve":return new a.Curve3D(this.parent,s);case "triangle":return new a.Triangle3D(this.parent,s);case "face":return new a.Face3D(this.parent,s);case "polireg":return new a.Polireg3D(this.parent,s);case "surface":return new a.Surface3D(this.parent,s);case "text":return new a.Text3D(this.parent,s);case "cube":case "box":case "tetrahedron":case "octahedron":case "sphere":case "dodecahedron":case "icosahedron":case "ellipsoid":case "cone":case "cylinder":case "mesh":return new a.OtherGeometry(this.parent,
s);default:console.log(s.type)}};a.LessonParser.prototype.parseAuxiliar=function(b){v={};b=this.split(b);for(var d=0,c=b.length;d<c;d++)b[d][1]=b[d][1].replace(/&squot;/g,"'");d=0;for(c=b.length;d<c;d++)switch(t=b[d][0],n=b[d][1],p=e[t],p){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":v[p]=n;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":v[p]=
"true"===e[n];break;case "size":case "rows":case "columns":v[p]=this.parser.parse(n);break;case "evaluate":case "execution":case "msg_pos":case "action":v[p]=e[n];break;default:var f=t.indexOf("."),j=e[t.substring(0,f)],f=e[t.substring(f+1)];if("parameter"===j&&"font"===f){v.parameterFont=n;break}console.log("----- attributo de auxiliar no identificado: <"+t+"> valor: <"+n+"> -----")}v.sequence?new a.Function(this.parent,v):v.constant?(b=new a.Constant(this.parent,v),v.evaluate&&"always"===v.evaluate&&
this.parent.auxiliaries.push(b)):v.algorithm&&v.evaluate?(b=new a.Algorithm(this.parent,v),this.parent.auxiliaries.push(b)):v.array&&!v.matrix&&")"!=v.id.charAt(v.id.length-1)?(b=new a.Vector(this.parent,v),v.evaluate&&"always"===v.evaluate&&this.parent.auxiliaries.push(b)):v.matrix&&")"!=v.id.charAt(v.id.length-1)?(b=new a.Matrix(this.parent,v),v.evaluate&&"always"===v.evaluate&&this.parent.auxiliaries.push(b)):v.event&&")"!=v.id.charAt(v.id.length-1)?this.parent.events.push(new a.Event(this.parent,
v)):")"===v.id.charAt(v.id.length-1)?new a.Function(this.parent,v):new a.Variable(this.parent,v)};a.LessonParser.prototype.parseAction=function(b){B=b.action;x=b.parent;D=b.parameter;if(B)switch(B){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: <"+B+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var d={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(t=b[c][0],n=b[c][1],p=e[t],p){case "id":case "delay":case "init":case "doExpr":case "whileExpr":d[p]=n;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":d[p]=
"true"===e[n];break;default:console.log("----- attributo de la animacion no identificado: <"+t+">  <"+n+"> -----")}return new a.Animation(this.parent,d)};a.LessonParser.prototype.parsePleca=function(e,h){e=this.split(e);k=g="";b=0;c="#536891";d="white";j="left";f="";r="SansSerif,BOLD,20";m="SansSerif,PLAIN,18";l=void 0;for(var p=0,q=e.length;p<q;p++)switch(t=e[p][0],n=e[p][1],t){case "title":g=n;break;case "subtitle":k=n;break;case "subtitlines":b=n;break;case "bgcolor":""!=n&&(c=(new a.Color(n,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=n&&(d=(new a.Color(n,this.parent.evaluator)).getColor());break;case "align":""!=n&&(j=n);break;case "titleimage":f=n;break;case "titlefont":r=""!=n?a.convertFont(n):a.convertFont(r);break;case "subtitlefont":m=""!=n?a.convertFont(n):a.convertFont(m);break;default:console.log("----- attributo de la pleca no identificado: <"+t+">  <"+n+"> -----")}if(""===g&&""===k)return document.createElement("div");J=m.substring(0,m.indexOf("px"));J=J.substring(J.lastIndexOf(" "));""!=f&&
(w=this.parent.getImage(f),I=w.height);l=document.createElement("div");l.setAttribute("id","descartesPleca");I?(l.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+j+"; width: "+(h-30)+"px; height: "+(I-16)+"px; background: "+c+"; color: "+d+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),w.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),
l.appendChild(w)):l.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+j+"; width: "+(h-30)+"px; background: "+c+"; color: "+d+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");E=document.createElement("div");E.setAttribute("style","padding: 0px; margin: 0px; font: "+r+"; overflow: hidden; white-space: nowrap;");E.innerHTML=g;O=document.createElement("div");if(1===parseInt(b)){M=0;P=document.createElement("div");
P.innerHTML=k;document.body.appendChild(P);Q=J;do Q-=M,P.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; font-size: "+Q+"px; width: "+(h-30)+"px; line-height: "+Q+"px;"),L=P.offsetHeight,R=L/Q,M=1;while(1<R&&8<Q);document.body.removeChild(P);O.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; font-size: "+Q+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else O.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; line-height: 110%;");O.innerHTML=
k;l.appendChild(E);l.appendChild(O);l.imageHeight=I;return l};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");C=[];z=A=0;G=!1;F=0;for(H=!1;A<a.length;)" "===a.charAt(A)&&!G&&A++," "!==a.charAt(A)&&!G&&(G=!0,F=A),"="===a.charAt(A)&&("'"===a.charAt(A+1)&&!H)&&(H=!0,C[z]=[a.substring(F,A)],F=A+2,A+=2),H&&"'"===a.charAt(A)&&(G=H=!1,C[z].push(a.substring(F,A)),z++),"="===a.charAt(A)&&("'"!==a.charAt(A+1)&&!H)&&(C[z]=[a.substring(F,A)],F=A+1,
A++,N=a.substring(A).indexOf("="),-1===N?K=N=a.length:(N+=A,K=a.substring(A,N).lastIndexOf(" "),K=-1===K?a.length:K+A),C[z].push(a.substring(F,K)),z++,G=!1,A=K),A++;return C};a.LessonParser.prototype.parseText=function(b){return b.match(/^\{\\rtf1/)?this.RTFparser.parse(b.substring(10)):new a.SimpleText(this.parent,b)};return a}(descartesJS||{},babel),descartesJS=function(a){function e(a,b){q=[];q.type="matrix";q.rows=a;q.cols=b;var d;t=0;for(n=b;t<n;t++){d=[];p=0;for(u=a;p<u;p++)d.push(0);q[t]=d}return q}
function g(a,b){m=a.rows;l=a.cols;q=e(m,l);var d;for(t=0;t<m;t++)for(p=0;p<l;p++){for(n=d=0;n<l;n++)d+=a[n][t]*b[p][n];q[p][t]=d}return q}function k(a,b,d){for(var c=e(d.length-1,d.length-1),f=0,j=c.length;f<j;f++)for(var k=0;k<j;k++)c[f][k]=f<a?k<b?d[f][k]:d[f][k+1]:f<b?d[f+1][k]:d[f+1][k+1];return c}function b(a){if(1<a.cols){for(var d=0,c=1,f=0,e=a.cols;f<e;f++)d+=c*a[0][f]*b(k(0,f,a)),c=-c;return d}return a[0][0]}if(a.loadLib)return a;var c=Math.floor,d,j,f,r;a.Node=function(a,b){this.sep="";
this.type=a;this.value=b;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null===this.parent?this:this.parent.getRoot()};a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){d=this.childs.length-1;lastChild=this.childs[d];lastChild.parent=null;this.childs[d]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,d=this.childs.length;b<d;b++)if(this.childs[b].contains(a))return!0;
return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",this.value="-",f=new a.Node("compOperator","=="),r=new a.Node("number","0"),f.addChild(this),f.addChild(r),j=this.getRoot(),j.setAllEvaluateFunction(),j):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.setEvaluateFunction=function(){if("number"===this.type)this.evaluate=
function(){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(){return this.value};else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(){return Math.random()};else{var a;this.evaluate=function(b,d){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);if(void 0==a&&(d||b.matrices[this.value]))a=b.matrices[this.value];return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&
1===this.childs[0].childs.length){var d,f;this.evaluate=function(a){d=this.childs[0].childs[0].evaluate(a);try{return f=a.vectors[this.value][0>d?0:c(d)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var j,n;this.evaluate=function(a){j=this.childs[0].childs[0].evaluate(a);n=this.childs[0].childs[1].evaluate(a);try{return f=a.matrices[this.value][0>j?0:c(j)][0>n?0:c(n)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===
this.type&&"parentheses"===this.childs[0].type){var r;this.evaluate=function(a){r=[];for(var b=0,d=this.childs[0].childs.length;b<d;b++)r[b]=this.childs[0].childs[b].evaluate(a);return"_Eval_"===this.value?(r[0]=0<r.length?r[0].toString():"",a.evalExpression(a.parser.parse(r[0].replace(a.parent.decimal_symbol_regexp,".")))):a.functions[this.value].apply(a,r)}}else if("operator"===this.type){var u,C,A;"+"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);C=this.childs[1].evaluate(a,
!0);if("matrix"!==u.type||"matrix"!==C.type)return u+C;a=u;var b=C;m=a.rows;l=a.cols;q=e(m,l);for(t=0;t<m;t++)for(p=0;p<l;p++)q[p][t]=a[p][t]+b[p][t];return q}:"-"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);C=this.childs[1].evaluate(a,!0);if("matrix"!==u.type||"matrix"!==C.type)return u-C;a=u;var b=C;m=a.rows;l=a.cols;q=e(m,l);for(t=0;t<m;t++)for(p=0;p<l;p++)q[p][t]=a[p][t]-b[p][t];return q}:"*"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);C=this.childs[1].evaluate(a,
!0);return"matrix"!==u.type||"matrix"!==C.type?u*C:g(u,C)}:"/"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);C=this.childs[1].evaluate(a,!0);if("matrix"!==u.type||"matrix"!==C.type)return u/C;a=u;var d;d=C;var c=e(d.length,d.length),f=b(d);if(0===f)d=0;else{var f=1/f,j;if(1<d.length)for(var h=0,l=d.length;h<l;h++){j=f;for(var m=0;m<l;m++)c[m][h]=j*b(k(h,m,d)),j=-j;f=-f}else c[0][0]=f;d=c}a=0===d?e(a.rows,a.cols):g(a,d);return a}:"%"===this.value?this.evaluate=function(a){u=
this.childs[0].evaluate(a);C=this.childs[1].evaluate(a);return u-c(u/C)*C}:"^"===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(u=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?
1:0:0}:"|"===this.value?this.evaluate=function(a){return(u=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){u=this.childs[0].evaluate(a)?1:0;return!u+0});else if("conditional"===this.type)this.evaluate=function(a){u=this.childs[0].evaluate(a);return 0<u?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate="sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};
else if("parentheses"===this.type)this.evaluate=function(a,b){return this.childs[0].evaluate(a,b)};else if("(expr)"===this.type||"[expr]"===this.type){var z,G;this.evaluate=function(a){z=this.childs.length;A=[];if(1===z&&1===this.childs[0].childs.length&&"(expr)"===this.type)A=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<z;b++){G=[];for(var d=0,c=this.childs[b].childs.length;d<c;d++)G.push(this.childs[b].childs[d].evaluate(a));A[b]=G}return A}}else if("asign"===this.type){var F,H,J,w,I,
E;this.evaluate=function(a){F=this.childs[0];H=this.childs[1];1===F.childs.length&&"square_bracket"===F.childs[0].type?(d=F.childs[0].childs,1===d.length?(J=d[0].evaluate(a),J=0>J?0:c(J),a.vectors[F.value][J]=H.evaluate(a)):2===d.length&&(w=d[0].evaluate(a),I=d[1].evaluate(a),w=0>w?0:c(w),I=0>I?0:c(I),a.matrices[F.value][w]||(a.matrices[F.value][w]=[]),a.matrices[F.value][w][I]=H.evaluate(a))):(E=H.evaluate(a),E.type?a.matrices[F.value]=E:"object"!==typeof a.variables[F.value]&&(a.variables[F.value]=
E))}}};var m,l,q,p,t,n,u;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var b=0,d=this.childs.length;b<d;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j,f,r,m=/^\s+/,l=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,q=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,p=/^==|^!=|^<=|^<|^>=|^>|^#/,
t=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,n=/^=/,u=/^[\?\:]/,h=/^[\+\-\*\/\%\^]/,s=/^\[|^\]/,v=/^\(|^\)/,y=/^,/,B=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function x(a,c,e){g.push({type:a,value:c});d=d.slice(e);b+=e;f++;r=a}if(e=a)a=a.replace(/\\u(\S+) /g,function(a,b){return String.fromCharCode(parseInt(b,16))}),a=a.replace(/\&sup(.+);/g,"^ $1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*","'","g").replace("*|","'","g")),a.match(/\=\|/g)&&(a=a.replace("|",
"'","g"));g=[];k=!1;b=0;d=a;f=0;for(r="";a&&b<a.length;)if(k=b,"'"==d[0]){for(j=1;"'"!=d[j];)if(j<d.length)j++;else{console.log(">Error, unknown symbol: ["+d+"], in the string <<"+e+">>");return}c=d.substring(1,j);x("string",c,c.length+2)}else if(c=d.match(m))d=d.slice(c[0].length),b+=c[0].length,f++;else if(c=d.match(l))"number"===r&&g.push({type:"operator",value:"*"}),x("identifier",c[0],c[0].length);else if(c=d.match(q))x("number",c[0],c[0].length);else if(c=d.match(p)){var z=c[0];"#"==z&&(z="!=");
x("compOperator",z,c[0].length)}else if(c=d.match(t))z=c[0],"||"==z?z="|":"&&"==z?z="&":"~"==z&&(z="!"),x("boolOperator",z,c[0].length);else if((c=d.match(n))&&!d.match(/^==/))x("asign",c[0],c[0].length);else if(c=d.match(u))x("conditional",c[0],c[0].length);else if(c=d.match(h))x("operator",c[0],c[0].length);else if(c=d.match(s))x("square_bracket",c[0],c[0].length);else if(c=d.match(v))"("==c&&"number"===r&&g.push({type:"operator",value:"*"}),x("parentheses",c[0],c[0].length);else if(c=d.match(y))x("separator",
c[0],c[0].length);else if(178===d.charCodeAt(0))g.push({type:"operator",value:"^"}),x("number",2,1);else if(179===d.charCodeAt(0))g.push({type:"operator",value:"^"}),x("number",3,1);else if(c=d.match(B))x("final_of_expresion",c[0],c[0].length);else if(k==b){console.log("Error, simbolo no conocido: ["+d+"], en la cadena <<"+e+">>");return}return g};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,b){a=a||[];b=b||"";x="";for(var d=0,c=a.length;d<c;d++)x="string"==a[d].type?x+"&squot;"+a[d].value+"&squot;":"identifier"==a[d].type&&!a[d].value.match(D)?x+b+a[d].value:x+a[d].value;return x};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Parser=function(b){this.evaluator=b;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.registerDefaultValues()};a.Parser.prototype.setVariable=
function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=function(a){return this.variables[a]};a.Parser.prototype.setVector=function(a,b,d){this.vectors[a][b]=d};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,b,d,c){this.matrices[a][b][d]=c};a.Parser.prototype.getMatrix=function(a){this.matrices.hasOwnProperty(a)||(this.matrices[a]=[[0,0,0],[0,0,0],[0,0,0]]);return this.matrices[a]};
a.Parser.prototype.setFunction=function(a,b){this.functions[a]=b};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var e,g,k,b,c,d,j,f,r,m,l,q;a.Parser.prototype.parse=function(p,t){(k=this.tokenizer.tokenize(p))||(k=[]);b=null;t=!t||!1;e=f=j=d=0;for(g=k.length;e<g;e++)if(r=k[e],m=r.value,l=r.type,"identifier"===l&&(e+1<g&&"parentheses"===k[e+1].type&&"("===k[e+1].value?this.getFunction(m):e+1<g&&"square_bracket"===
k[e+1].type&&"["===k[e+1].value?k[e+3]&&"square_bracket"===k[e+3].type&&"]"===k[e+3].value?this.getVector(m):this.getMatrix(m):this.getVariable(m)),"asign"===l&&t&&(l="compOperator",m="=="),"asign"===l)if(c=new a.Node(l,m),null!=b)if("identifier"===b.type)b.parent&&b.parent.replaceLastChild(c),c.addChild(b),b=c,t=!0;else if("square_bracket"===b.type)c.addChild(b.parent),b=c,t=!0;else{c.type="compOperator";c.value="==";for(t=!0;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(c.value);)b=
b.parent;b.parent&&b.parent.replaceLastChild(c);c.addChild(b);b=c}else{console.log("Error1: en la expresion <<"+p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("parentheses"===l&&"("===m||"square_bracket"===l&&"["===m)if(c=new a.Node(l,m),"("===m&&d++,"["===m&&j++,null===b)"("===m&&(new a.Node("(expr)","(expr)")).addChild(c),"["===m&&(new a.Node("[expr]","[expr]")).addChild(c),b=c;else if("operator"===b.type||"boolOperator"===b.type||"compOperator"===b.type||"conditional"===b.type||
"asign"===b.type)b.addChild(c),b=c;else if("sign"===b.type)b.addChild(c),b=c;else if("parentheses"===b.type&&"("===b.value)b.addChild(c),b=c;else if("square_bracket"===b.type&&"["===b.value)b.addChild(c),b=c;else if("parentheses"===b.type&&"()"===b.value)b.parent.addChild(c),b=c;else if("square_bracket"===b.type&&"[]"===b.value)b.parent.addChild(c),b=c;else if("identifier"===b.type)b.addChild(c),b=c;else{console.log("Error2: en la expresion <<"+p+">>, en el token ["+e+"] {valor: "+m+", tipo: "+l+
"}");break}else if("parentheses"===l&&")"===m)if(d--,null===b)console.log("Error3: en la expresion <<"+p+">>, en el token (valor:"+m+", tipo:"+l);else{for(;b&&b.parent&&"("!=b.value;)b=b.parent;if(b&&"("===b.value)b.value="()";else{console.log("Error4: en la expresion <<"+p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else if("square_bracket"===l&&"]"===m)if(j--,null===b)console.log("Error5: en la expresion <<"+p+">>, en el token (valor:"+m+", tipo:"+l);else{for(;b&&b.parent&&"["!=b.value;)b=
b.parent;if(b&&"["===b.value)b.value="[]";else{console.log("Error6: en la expresion <<"+p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else if("number"===l||"string"===l||"identifier"===l)if(c=new a.Node(l,m),null===b)b=c;else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"parentheses"===b.type&&"("===b.value||"square_bracket"===b.type&&"["===b.value||"sign"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(c),b=c;else{console.log("Error7: en la expresion <<"+
p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("operator"===l||"compOperator"===l||"boolOperator"===l)if(c=new a.Node(l,m),null===b)if("-"===m||"+"===m)c.type="sign",c.value="sign"+m,b=c;else if("!"===m)b=c;else{console.log("Error8: en la expresion <<"+p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"asign"===b.type||"conditional"===b.type||"square_bracket"===b.type&&"["===b.value&&("-"===m||"+"===
m||"!"===m)||"parentheses"===b.type&&"("===b.value&&("-"===m||"+"===m||"!"===m)){if("-"===m||"+"===m)c.type="sign",c.value="sign"+m;b.addChild(c);b=c}else if("number"===b.type||"parentheses"===b.type&&"()"===b.value||"square_bracket"===b.type&&"[]"===b.value||"string"===b.type||"identifier"===b.type||"conditional"===b.type||"asign"===b.type){for(;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(c.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(c);c.addChild(b);b=c}else{console.log("Error9: en la expresion <<"+
p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("conditional"===l)if(c=new a.Node(l,m),null!=b)if("?"===c.value){for(f++;b.parent&&this.getPrecedence(b.parent.value)>this.getPrecedence(c.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(c);c.addChild(b);b=c}else{for(f--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"===b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else{console.log("Error11: en la expresion <<"+
p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("separator"===l)if(null!=b)for(;b.parent&&"("!=b.value&&"["!=b.value;)b=b.parent;else{console.log("Error12: en la expresion <<"+p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else{console.log("Error13: en la expresion <<"+p+">>, en el token {valor: "+m+", tipo: "+l+"}");break}0<d&&alert("Error, faltan parentesis por cerrar: "+p);0>d&&alert("Error, faltan parentesis por abrir: "+p);0<j&&alert("Error, faltan square bracketss por cerrar: "+
p);0>j&&alert("Error, faltan square bracketss por abrir: "+p);0!=f&&alert("Error, condicional incompleta: "+p);(q=b?b.getRoot():null)&&q.setAllEvaluateFunction();return q};a.Parser.prototype.getPrecedence=function(a){switch(a){case "=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;
case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "%":return 8;case "^":return 9;default:return 9}};a.Parser.prototype.registerDefaultValues=function(){this.variables.rnd=Math.random;this.variables.pi=Math.PI;this.variables.e=Math.E;this.variables.Infinity=Infinity;this.variables["-Infinity"]=-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=Math.sqrt;this.functions.exp=Math.exp;
this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=function(a){return 1/Math.sin(a)};
this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=Math.asin;this.functions.acos=
Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;var b=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){b.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(d,c,f){return a.esCorrecto(d,c,b.evaluator,f)};this.functions.escorrecto=function(d,c,f){return a.escorrecto(d,c,b.evaluator,f)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",
name:a,value:b},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*")});this.functions._GetValues_=function(d,c){var f=a.openExternalFile(d),e=-1,j=-1,h=[];if(f){f=f.replace(/\r/g,"").split("\n");e=f.indexOf("<"+c+">");j=f.indexOf("</"+c+">");if(-1!=e&&-1!=j&&e<j)for(e+=1;e<j;e++)h=h.concat(f[e].split("\u00a6"));e=0;for(j=h.length;e<j;e++)f=h[e].split("="),
f[0]=f[0].trim(),""!=f[0]&&(isNaN(parseFloat(f[1]))?b.setVariable(f[0],f[1].replace(/^\s|\s$/g,"")):b.setVariable(f[0],parseFloat(f[1])))}return 0};this.functions._GetMatrix_=function(d,c){var f=a.openExternalFile(d),e=-1,j=-1,h=[];h.type="matrix";if(f&&(f=f.replace(/\r/g,"").split("\n"),e=f.indexOf("<"+c+">"),j=f.indexOf("</"+c+">"),-1!=e&&-1!=j&&e<j)){for(e+=1;e<j;e++)h.push(f[e].split("\u00a6").map(function(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,""):parseFloat(a)}));b.matrices[c]=
h;b.setVariable(c+".filas",h[0].length);b.setVariable(c+".columnas",h.length)}return 0};var d=document.createElement("a"),c;this.functions._Save_=function(a,b){document.body.appendChild(d);c=new Blob([b],{type:"text/plain"});d.setAttribute("download",a);d.setAttribute("href",window.URL.createObjectURL(c));d.click();document.body.removeChild(d);return 0};var f,e,j,k,g=document.createElement("input");g.setAttribute("type","file");onHandleFileSelect=function(d){f=d.target.files;e=new FileReader;e.onload=
function(d){a.addExternalFileContent(f[0].name,d.target.result);b.setVariable(j,f[0].name);b.getFunction(k)&&(b.getFunction(k).apply(b.evaluator,[]),b.evaluator.parent.update())};0<f.length&&e.readAsText(f[0])};g.addEventListener("change",onHandleFileSelect);this.functions._Open_=function(a,b){j=a;k=b;g.click();return 0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Evaluator=function(e){this.parent=e;this.parser=new a.Parser(this);this.variables=this.parser.variables;
this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices};a.Evaluator.prototype.setVariable=function(a,e){this.variables[a]=e};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,k,b){k=0>k?0:e(k);this.vectors[a][k]=b};a.Evaluator.prototype.getVector=function(a,k){k=0>k?0:e(k);return this.vectors[a][k]};a.Evaluator.prototype.setMatrix=function(a,k,b,c){k=0>k?0:e(k);b=0>b?0:e(b);this.matrices[a][k][b]=
c};a.Evaluator.prototype.getMatrix=function(a,k,b){k=0>k?0:e(k);b=0>b?0:e(b);return this.matrices[a][k][b]};a.Evaluator.prototype.setFunction=function(a,e){this.functions[a]=e};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2,g=!1;a.RTFNode=function(a,b,c,e){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=
c;this.style=e;this.styleString=e.toString();this.color=e.textColor;this.underline=e.textUnderline;this.overline=e.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;case "superIndex":this.draw=this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=
this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;break;case "matrix":this.draw=this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=
this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":this.draw=this.drawComponentSpace}};a.RTFNode.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.children.push(a)};var k=0,b=0,
c=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var d=0,j=this.children.length;d<j;d++)this.children[d].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 f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;
this.ascent=f.ascent;this.w=f.w;this.h=f.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;var d=this.value,r;"string"!=typeof this.value&&(j=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),r=void 0==this.fixed?g:this.fixed,d=this.evaluator.evalExpression(this.value,j,r),parseFloat(d)==d&&(d=parseFloat(d).toFixed(j),
d=r?d:parseFloat(d),d=d.toString().replace(".",this.decimal_symbol)),d+=" ");this.w=a.getTextWidth(d,this.styleString);this.h=f.h}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType){d=a.getFontMetrics(this.styleString);this.baseline=d.baseline;this.descent=d.descent;this.ascent=d.ascent;this.w=a.getTextWidth(this.value,this.styleString);this.h=d.h;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style",
"position: absolute; width: "+this.w+"px; height: "+this.h+"px; cursor: pointer;");var m=this;this.clickCacher.addEventListener("click",function(){m.click=!0;window.open(m.URL,m.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=k,f=b,j=c,d=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=d.ascent,this.descent=d.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),d=j/2-f+this.h,this.superIndexPos=d-this.ascent,
this.ascent=d,this.descent=f,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=k,f=b,j=c,d=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=d.ascent,this.descent=d.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=f+1,this.ascent=r,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("fraction"==
this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);r=k;f=b;j=c;r=this.children[0];var l=this.children[1],d=a.getFontMetrics(r.styleString);r.getBlockMetric();l.getBlockMetric();0>r.h&&(r.h=d.h,r.w=this.spaceWidth);0>l.h&&(l.h=d.h,l.w=this.spaceWidth);this.h=r.h+l.h-1;this.ascent=r.h+j/2-f;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(r.w,l.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=this.children[0].style.clone();
if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",f),this.children[1].addChild(this.children[0]),this.children[0]=new a.RTFNode(this.evaluator," ","index",f);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){r=new a.RTFNode(this.evaluator,"","radicand",f);d=0;for(j=this.children.length;d<j;d++)r.addChild(this.children[d]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",f);this.children[1]=r}d=this.children[0];
j=this.children[1];0>=d.children.length&&(f=this.style.clone(),f.fontSize=parseInt(f.fontSize-0.2*f.fontSize),d.addChild(new a.RTFNode(this.evaluator," ","text",f)));0>=j.children.length&&j.addChild(new a.RTFNode(this.evaluator," ","text",this.style.clone()));d.getBlockMetric();j.getBlockMetric();this.ascent=j.h/2<d.h?j.h/2+d.h+2-j.descent:j.ascent+4;this.descent=j.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=d.w+j.w+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=
a.getTextWidth(" ",this.styleString),r=k,f=b,j=c,f=this.children[0],j=this.children[1],r=this.children[2],f.getBlockMetric(),j.getBlockMetric(),r.getBlockMetric(),-1==f.ascent&&(l=a.getFontMetrics(f.styleString),f.ascent=l.ascent,f.descent=l.descent,f.h=l.h),-1==j.ascent&&(l=a.getFontMetrics(j.styleString),j.ascent=l.ascent,j.descent=l.descent,j.h=l.h),d=a.getFontMetrics(this.styleString),this.ascent=d.h+j.h>r.ascent?d.h-d.descent+j.h:r.ascent,this.descent=f.h>r.descent?f.h+d.descent:r.descent,this.baseline=
this.ascent,this.h=this.ascent+this.descent,d=this.style.clone(),d.fontType="Times New Roman",d.Bold="bold",d=d.toString(),d=a.getTextWidth(String.fromCharCode(8721),d),this.w=Math.max(f.w,j.w,d)+Math.max(r.w,this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=k,f=b,j=c,f=this.children[0],j=this.children[1],r=this.children[2],f.getBlockMetric(),j.getBlockMetric(),r.getBlockMetric(),-1==f.ascent&&(l=a.getFontMetrics(f.styleString),
f.ascent=l.ascent,f.descent=l.descent,f.h=l.h),-1==j.ascent&&(l=a.getFontMetrics(j.styleString),j.ascent=l.ascent,j.descent=l.descent,j.h=l.h),d=a.getFontMetrics(this.styleString),this.ascent=d.h+j.h>r.ascent?d.h-d.descent+j.h:r.ascent,this.descent=f.h>r.descent?f.h+d.descent:r.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,d=this.style.clone(),d.fontSize*=1.5,d.fontType="Times New Roman",d.Bold="bold",d=d.toString(),d=a.getTextWidth(String.fromCharCode(8747),d),this.w=Math.max(f.w,
j.w,d)+Math.max(r.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=k,f=b,j=c,f=this.children[0],j=this.children[1],r=this.children[2],d=a.getFontMetrics(this.styleString),f.getBlockMetric(),j.getBlockMetric(),r.getBlockMetric(),-1==f.ascent&&(l=a.getFontMetrics(f.styleString),f.ascent=l.ascent,f.descent=l.descent,f.h=l.h),-1==j.ascent&&(l=a.getFontMetrics(j.styleString),j.ascent=l.ascent,j.descent=l.descent,j.h=l.h),-1==r.ascent&&
(l=a.getFontMetrics(r.styleString),r.ascent=l.ascent,r.descent=l.descent,r.h=l.h),this.ascent=r.ascent,this.descent=Math.max(d.h,r.descent),this.baseline=this.ascent,this.h=this.ascent+this.descent,d=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==f.w&&(f.w=this.spaceWidth),0==j.w&&(j.w=this.spaceWidth),0==r.w&&(r.w=this.spaceWidth),this.w=j.w+f.w+r.w+d+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);d=a.getFontMetrics(this.styleString);
r=k;f=b;j=c;r=d.ascent;for(var l=d.descent,q=d.h,p=this.spaceWidth,t,n,d=0,j=this.children.length;d<j;d++)this.children[d].getBlockMetric(),t=this.children[d].h,n=this.children[d].w,q<t&&(q=t,r=this.children[d].ascent,l=this.children[d].descent),p<n&&(p=n);this.childWidth=p+2*this.spaceWidth;this.childh=q;this.childAscent=r;this.childDescent=l;this.h=this.rows*q;this.ascent=this.h/2+f;this.descent=this.h-this.ascent;this.w=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=
a.getTextWidth(" ",this.styleString);d=a.getFontMetrics(this.styleString);r=k;f=b;j=c;r=d.ascent;l=d.descent;q=d.h;p=this.spaceWidth;d=0;for(j=this.children.length;d<j;d++)this.children[d].getBlockMetric(),t=this.children[d].h,n=this.children[d].w,q<t&&(q=t,r=this.children[d].ascent,l=this.children[d].descent),p<n&&(p=n);this.childWidth=p+2*this.spaceWidth;this.childh=q;this.childAscent=r;this.childDescent=l;this.h=this.parts*q;this.ascent=this.h/2+f;this.descent=this.h-this.ascent;this.w=p+this.spaceWidth/
2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),f=a.getFontMetrics(this.styleString),this.baseline=f.baseline,this.descent=f.descent,this.ascent=f.ascent,this.w=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.h=f.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),f=this.componentNumCtrl.h||0,this.baseline=Math.round(3*
f/5),this.descent=Math.round(2*f/5),this.ascent=this.baseline,this.h=f,this.w=this.componentNumCtrl.w):"componentSpace"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentSpace=this.evaluator.parent.getSpaceByCId(this.value),this.h=this.ascent=this.descent=this.baseline=0,this.w=this.componentSpace.w):console.log("Element i=unknown",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.w=0;for(var a=-1,e=-1,f,g=0,m=this.children.length;g<m;g++){f=this.children[g];
f.getTextMetrics();childAscent=f.ascent;childDescent=f.descent;this.w+=f.w;var l=childDescent;f=f.h;k=childAscent;b=l;c=f;e<childAscent&&(e=childAscent);a<childDescent&&(a=childDescent)}this.ascent=e;this.descent=a;this.baseline=this.ascent;this.h=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,c,k,m,l,q){this.stableWidth||(this.getTextMetrics(),e=k,g=m);q=q?-this.children[0].ascent:0;m=k=0;for(l=this.children.length;m<l;m++)0<m&&(k+=this.children[m-1].h),this.children[m].draw(a,
b+0,c+q+k)};a.RTFNode.prototype.drawTextLineBlock=function(b,c,f){for(var e=0,k=0,g=this.children.length;k<g;k++)0<k&&(e+=this.children[k-1].w,"formula"==this.children[k-1].nodeType&&(e+=2*a.getTextWidth(" ",this.children[k].styleString))),this.children[k].draw(b,c+e,f+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var e=0,k=0,g=this.children.length;k<g;k++)0<k&&(e+=this.children[k-1].w),this.children[k].draw(a,b+this.spaceWidth+e,c)};a.RTFNode.prototype.drawText=function(a,b,
c){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);if(this.underline){var e="bold"==this.style.textBold,k=e?1:0.5;a.lineWidth=e?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(c+this.descent/2)+k);a.lineTo(b-1+this.w,parseInt(c+this.descent/2)+k);a.stroke()}this.overline&&(k=(e="bold"==this.style.textBold)?2:1.5,a.lineWidth=e?2:1,null!=this.color&&(a.strokeStyle=this.color),
a.beginPath(),a.moveTo(b-1,parseInt(c-this.ascent)+k),a.lineTo(b-1+this.w,parseInt(c-this.ascent)+k),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,c,f){var k=Math.floor(0.5*this.spaceWidth),m=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),l=void 0==this.fixed?g:this.fixed,q=this.evaluator.evalExpression(this.value,m,l);parseFloat(q).toString()===q.toString()&&(q=l?parseFloat(q).toFixed(m):parseFloat(parseFloat(q).toFixed(m)),q=(""+q).replace(".",this.decimal_symbol));
null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";this.w=a.getTextWidth(q,this.styleString);b.fillText(q,k+c,f);this.underline&&(l=(m="bold"==this.style.textBold)?1:0.5,b.lineWidth=m?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(k+c-1,parseInt(f+this.descent/2)+l),b.lineTo(k+c-1+this.w,parseInt(f+this.descent/2)+l),b.stroke());this.overline&&(l=(m="bold"==this.style.textBold)?2:1.5,b.lineWidth=m?2:1,null!=this.color&&
(b.strokeStyle=this.color),b.beginPath(),b.moveTo(k+c-1,parseInt(f-this.ascent)+l),b.lineTo(k+c-1+this.w,parseInt(f-this.ascent)+l),b.stroke());this.w+=2*k};a.RTFNode.prototype.drawHyperlink=function(a,b,c){this.clickCacher.parentNode||(a.canvas.nextSibling.className?a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling.nextSibling):a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling),this.clickCacher.style.left=b-2+"px",this.clickCacher.style.top=c-this.ascent-
2+"px");a.save();this.click?(a.fillStyle="red",a.strokeStyle="red"):(a.fillStyle="blue",a.strokeStyle="blue");a.font=this.styleStr;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);var e="bold"==this.style.textBold,k=e?1:0.5;a.lineWidth=e?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(c+this.descent/2)+k-2);a.lineTo(b-1+this.w,Math.ceil(c+this.descent/2)+k-2);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,c){var e=Math.floor(this.spaceWidth);this.children[0].draw(a,
b,Math.floor(c+this.children[1].descent-this.children[1].h/2-this.children[0].descent));this.children[1].draw(a,b+1.5*e+this.children[0].w,c);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b,Math.floor(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w,Math.floor(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w+0.5*e,c+this.children[1].descent);a.lineTo(b+this.children[0].w+1*e,c-this.children[1].ascent);
a.lineTo(b+this.children[0].w+2*e+this.children[1].w,c-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,b,c){this.children[0].draw(a,b+(this.w-this.children[0].w)/2,c-this.ascent);this.children[1].draw(a,b+(this.w-this.children[1].w)/2,c-this.ascent+this.children[0].h-1);var e=Math.floor(0.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b+e,parseInt(c-this.ascent+this.children[0].h)-0.5);a.lineTo(b-e+this.w-1,parseInt(c-
this.ascent+this.children[0].h)-0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,c){for(var e=0,k=0,g=this.children.length;k<g;k++)0<k&&(e+=this.children[k-1].w),this.children[k].draw(a,b+e,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,c){for(var e=0,k=0,g=this.children.length;k<g;k++)0<k&&(e+=this.children[k-1].w),this.children[k].draw(a,b+e,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var e=0,k=0,g=this.children.length;k<g;k++)0<k&&(e+=
this.children[k-1].w),this.children[k].draw(a,b+e,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,c,f){var e=a.getFontMetrics(this.styleString),k=" "+String.fromCharCode(8594),g=a.getTextWidth(k,this.styleString);this.children[0].draw(b,c,f+e.descent+this.children[0].ascent);this.children[1].draw(b,c+this.children[0].w+g,f+e.descent+this.children[1].ascent);this.children[2].draw(b,c+g+this.children[0].w+this.children[1].w,f);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;
b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",c+this.children[0].w,f);b.fillText(k,c+this.children[0].w,f+e.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,c,f){var e=this.style.clone();e.fontSize*=1.5;e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),k=a.getTextWidth(String.fromCharCode(8747),e),g=a.getFontMetrics(e),q=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*k));this.children[0].draw(b,c+k,f+g.descent+this.children[0].ascent);
this.children[1].draw(b,c+k+this.spaceWidth/2,f-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+q+k,f);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),c,f+g.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,f){var e=this.style.clone();e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),k=a.getTextWidth(String.fromCharCode(8721),e),g=a.getFontMetrics(this.styleString),q=Math.max(this.children[0].w,
this.children[1].w,k);this.children[0].draw(b,c+(q-this.children[0].w)/2,f+g.descent+this.children[0].ascent);this.children[1].draw(b,c+(q-this.children[1].w)/2,f-g.ascent-this.children[1].descent);this.children[2].draw(b,c+q,f);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((q-k)/2),f-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var e,k,g=0,q=this.children.length;g<q;g++)e=g%this.columns,
k=Math.floor(g/this.columns),this.children[g].draw(a,2*this.spaceWidth+b+e*this.childWidth,c-this.ascent+this.childAscent+k*this.childh);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(b+this.spaceWidth)+0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.spaceWidth)+0.5,c+this.descent+0.5);a.moveTo(Math.floor(b+this.w-this.spaceWidth)-
0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth)-0.5,c+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,b,c){for(var e=0,k=this.children.length;e<k;e++)this.children[e].draw(a,b+3*this.spaceWidth,c-this.ascent+this.childAscent+e%this.parts*this.childh);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();
a.moveTo(parseInt(b+2*this.spaceWidth)+0.5,c-this.ascent+0.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c-this.ascent+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-this.h/2-4.5);a.lineTo(b-0.5,c+this.descent-this.h/2);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-this.h/2+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-4.5);a.lineTo(parseInt(b+2*this.spaceWidth)+0.5,c+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,b,c){a.lineWidth=
1;null!=this.color&&(a.strokeStyle=this.color,a.fillStyle=this.color);a.beginPath();"("==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText("(",b,c)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",b+this.spaceWidth,c)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,b+this.w/2,c))};a.RTFNode.prototype.drawGenericBlock=function(a,b,c){for(var e=0,k=0,
g=this.children.length;k<g;k++)0<k&&(e+=this.children[k-1].w),this.children[k].draw(a,b+e,c)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,c){this.parent.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+b+","+(c-this.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,c){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b+"");this.componentSpace.yExpr=this.evaluator.parser.parse(c-
this.parent.ascent+"")};a.RTFNode.prototype.draw=function(){console.log(">>> Dibujo desconocido ",this.nodeType)};a.RTFNode.prototype.toHTML=function(){var a="";if("textLineBlock"===this.nodeType||"textBlock"===this.nodeType)for(var b=0,c=this.children.length;b<c;b++)a+=this.children[b].toHTML();else"text"===this.nodeType?a="<span "+this.style.toCSS()+">"+this.value+"</span>":"newLine"===this.nodeType&&(a="<span "+this.style.toCSS()+">"+this.value+"<br /></span>");return a};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=String.fromCharCode,g,k,b,c,d,j,f,r,m,l,q;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&quote;/g,"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];g=[];k=a.length;g=[];b="";d=c=0;f=a.charAt(0);r=!1;for(m="text";c<k;)j=
f,f=a.charAt(c+1),r?"\\"===f||"{"===f||"}"===f||" "===f||";"===f?(r=!1,b+=j," "===f&&(c++,f=a.charAt(c+1)),(l=b.match(/^\'([0-9a-f]{2})/))?(q="","text"===m&&(q=g.pop().value),b=q+=e(parseInt(l[1],16))+b.substring(3)):(l=b.match(/^u[0-9]+/))?(q="","text"===m&&(q=g.pop().value),b=q+=e(l[0].substring(1))):("{"===b||"}"===b?(g.push({type:"text",value:b}),m="text"):(g.push({type:"controlWord",value:b}),m="controlWord"),b="")):b+=j:"\\"===j?(r=!0,""!==b&&(g.push({type:"text",value:b}),m="text"),b=""):"{"===
j?(d++,""!==b&&g.push({type:"text",value:b}),b="",g.push({type:"openBlock",value:d}),m="openBlock"):"}"===j?(""!==b&&g.push({type:"text",value:b}),b="",g.push({type:"closeBlock",value:d}),m="closeBlock",d--):b+=j,c++;""!==b&&g.push({type:"text",value:b});return g};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j,f,r,m,l,q,p,t,n,u,h,s,v,y,B,x,D,C,A,z,G,F,H,J;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=
function(w){w=e=this.tokenizer.tokenize(w);for(var I=[],E=!1,O=!1,P=[],L=0,Q=w.length;L<Q;L++){"openBlock"==w[L].type&&P.push(w[L].value);"closeBlock"==w[L].type&&(P.pop(),0>=P.length&&(E=!1));if("controlWord"==w[L].type&&("expr"==w[L].value||"decimals"==w[L].value))O=!0;"controlWord"==w[L].type&&"mjaformula"==w[L].value&&(E=!0);if("text"==w[L].type&&E&&!O){for(var R=0,M=w[L].value,N="",K=0,T=M.length;K<T;K++)if("("==M.charAt(K)||")"==M.charAt(K)||"+"==M.charAt(K)||"-"==M.charAt(K)||"*"==M.charAt(K)||
"="==M.charAt(K))N=M.substring(R,K),""!=N&&I.push({type:"text",value:N}),I.push({type:M.charAt(K),value:M.charAt(K)}),R=K+1;N=M.substring(R,K);""!=N&&I.push({type:"text",value:N})}else I.push(w[L]),"text"==w[L].type&&O&&(O=!1)}e=I;g={};b=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(k=e[0].value;"closeBlock"!=e[b].type&&e[b].value!=k;)g[e[b].value]=e[b+2].value.substring(0,e[b+2].value.length-1),b+=3;b++}c={};d=0;if("openBlock"==e[b].type&&"colortbl"==e[b+1].value){k=e[b++].value;for(b++;"closeBlock"!=
e[b].type&&e[b].value!=k;)j=parseInt(e[b++].value.substring(3)).toString(16),f=parseInt(e[b++].value.substring(5)).toString(16),r=parseInt(e[b++].value.substring(4)).toString(16),";"===e[b].value&&b++,c[d++]="#"+(2>j.length?"0"+j:j)+(2>f.length?"0"+f:f)+(2>r.length?"0"+r:r);b++}m=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");l=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");m.addChild(l);t=p=q=null;y=v=s=h=u=n=!1;B=[new a.FontStyle(20,"Arial","","",!1,!1,null)];x=B[0];D=!0;A=C=-1;
z=[];J=H=F=G=!1;w=b;for(I=e.length;w<I;w++)if("controlWord"==e[w].type&&g[e[w].value])x.fontType=g[e[w].value];else if("controlWord"==e[w].type&&e[w].value.match(/^fs(\d+)/))x.fontSize=parseInt(e[w].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==e[w].type&&"b"==e[w].value)x.textBold="bold";else if("controlWord"==e[w].type&&"b0"==e[w].value)x.textBold="";else if("controlWord"==e[w].type&&"i"==e[w].value)x.textItalic="italic";else if("controlWord"==e[w].type&&"i0"==e[w].value)x.textItalic="";
else if("controlWord"==e[w].type&&"ul"==e[w].value)x.textUnderline=!0;else if("controlWord"==e[w].type&&"ulnone"==e[w].value)x.textUnderline=!1;else if("controlWord"==e[w].type&&"ol"==e[w].value)x.textOverline=!0;else if("controlWord"==e[w].type&&"olnone"==e[w].value)x.textOverline=!1;else if("controlWord"==e[w].type&&e[w].value.match(/^cf(\d+)/))x.textColor=c[parseInt(e[w].value.substring(2))];else if("openBlock"==e[w].type)C=e[w].value,x=x.clone(),B.push(x),z.push(null);else if("closeBlock"==e[w].type)e[w].value==
A&&(A=-1,n=!1,l=l.parent),B.pop(),x=B[B.length-1],z.pop();else if("controlWord"==e[w].type&&"par"==e[w].value){l.addChild(new a.RTFNode(this.evaluator,"","newLine",x.clone()));m=new a.RTFNode(this.evaluator,"","textLineBlock",x.clone());if("textBlock"!=l.nodeType)for(l=l.parent;"textBlock"!=l.nodeType;)l=l.parent;l.addChild(m);l=m}else if("controlWord"==e[w].type&&"mjaformula"==e[w].value)G=!0,A=C,n=!0,m=new a.RTFNode(this.evaluator,"","formula",x.clone()),l.addChild(m),l=m,z[z.length-1]=m;else if("controlWord"==
e[w].type&&("fraction"==e[w].value||"radicand"==e[w].value||"radical"==e[w].value||"what"==e[w].value||"sum"==e[w].value||"integral"==e[w].value||"limit"==e[w].value))E=z[z.length-2].style.clone(),m=new a.RTFNode(this.evaluator,"",e[w].value,E),z[z.length-2].addChild(m),z[z.length-1]=m;else if("controlWord"==e[w].type&&"index"==e[w].value||"to"==e[w].value||"from"==e[w].value)E=z[z.length-2].style.clone(),E.fontSize=parseInt(E.fontSize-0.2*E.fontSize),8>E.fontSize&&(E.fontSize=8),m=new a.RTFNode(this.evaluator,
"",e[w].value,E),z[z.length-2].addChild(m),z[z.length-1]=m;else if("controlWord"==e[w].type&&("num"==e[w].value||"den"==e[w].value))E=z[z.length-2].style.clone(),E.fontSize=Math.round(E.fontSize-0.1*E.fontSize),8>E.fontSize&&(E.fontSize=8),"num"==e[w].value?m=new a.RTFNode(this.evaluator,"","numerator",E):"den"==e[w].value&&(m=new a.RTFNode(this.evaluator,"","denominator",E)),z[z.length-2].addChild(m),z[z.length-1]=m;else if("controlWord"==e[w].type&&("subix"==e[w].value||"supix"==e[w].value))E=z[z.length-
2].style.clone(),E.fontSize=Math.floor(E.fontSize-E.fontSize/3),8>E.fontSize&&(E.fontSize=8),"subix"==e[w].value?m=new a.RTFNode(this.evaluator,"","subIndex",E):"supix"==e[w].value&&(m=new a.RTFNode(this.evaluator,"","superIndex",E)),m.originalStyle=z[z.length-2].style.clone(),z[z.length-2].addChild(m),z[z.length-1]=m;else if("controlWord"==e[w].type&&("defparts"==e[w].value||"matrix"==e[w].value||"element"==e[w].value))E=z[z.length-2].style.clone(),m=new a.RTFNode(this.evaluator,"",e[w].value,E),
z[z.length-2].addChild(m),z[z.length-1]=m,"defparts"==e[w].value?t=m:"matrix"==e[w].value&&(p=m);else if("controlWord"==e[w].type&&"parts"==e[w].value)y=!0;else if("text"==e[w].type&&y)t.parts=parseInt(e[w].value),y=!1;else if("controlWord"==e[w].type&&"rows"==e[w].value)s=!0;else if("text"==e[w].type&&s)p.rows=parseInt(e[w].value),s=!1;else if("controlWord"==e[w].type&&"columns"==e[w].value)v=!0;else if("text"==e[w].type&&v)p.columns=parseInt(e[w].value),v=!1;else if("controlWord"==e[w].type&&"expr"==
e[w].value)D=!1,u=!0;else if("controlWord"==e[w].type&&"decimals"==e[w].value)h=!0;else if("text"==e[w].type&&h)q.decimals=this.evaluator.parser.parse(e[w].value+""),h=!1;else if("controlWord"==e[w].type&&"fixed1"==e[w].value)q.fixed=!0;else if("controlWord"==e[w].type&&"fixed0"==e[w].value)q.fixed=!1;else if(!("controlWord"==e[w].type&&"component"==e[w].value))if("controlWord"==e[w].type&&"NumCtrl"==e[w].value)F=!0;else if("controlWord"==e[w].type&&"Space"==e[w].value)H=!0;else if("controlWord"==
e[w].type&&"hyperlink"==e[w].value)J=!0;else if("text"==e[w].type&&J){textContent=e[w].value.split("|")[0];E=x.clone();m=new a.RTFNode(this.evaluator,textContent,"hyperlink",E);m.URL=e[w].value.split("|")[1];if("textLineBlock"!=l.nodeType)for(l=l.parent;"textLineBlock"!=l.nodeType;)l=l.parent;l.addChild(m);J=!1}else if("text"==e[w].type&&F)m=new a.RTFNode(this.evaluator,e[w].value,"componentNumCtrl",x.clone()),l.addChild(m),F=!1;else if("text"==e[w].type&&H)m=new a.RTFNode(this.evaluator,e[w].value,
"componentSpace",x.clone()),l.addChild(m),H=!1;else if("text"==e[w].type&&u)E=z[z.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[w].value),m=new a.RTFNode(this.evaluator,textContent,"dynamicText",E),z[z.length-2].addChild(m),q=z[z.length-1]=m,u=!1;else if("text"==e[w].type&&!u&&!n){textContent=e[w].value;m=new a.RTFNode(this.evaluator,textContent,"text",x.clone());if("textLineBlock"!=l.nodeType)for(l=l.parent;"textLineBlock"!=l.nodeType;)l=l.parent;l.addChild(m)}else if("text"==
e[w].type&&!u&&n)textContent=e[w].value,m=new a.RTFNode(this.evaluator,textContent,"text",z[z.length-1].style.clone()),z[z.length-1].addChild(m);else if("("==e[w].type||")"==e[w].type)E=z[z.length-1].style.clone(),E.textItalic="",m=new a.RTFNode(this.evaluator,e[w].type,"mathSymbol",E),z[z.length-1].addChild(m);else if("+"==e[w].type||"-"==e[w].type||"*"==e[w].type||"="==e[w].type)m=new a.RTFNode(this.evaluator,e[w].type,"mathSymbol",z[z.length-1].style.clone()),z[z.length-1].addChild(m);if(null!=
l){var S=l.getRoot();S.stableWidth=D;S.getTextMetrics();S.hasFormula=G}return S};a.FontStyle=function(a,b,c,d,f,e,k){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=f;this.textOverline=e;this.textColor=k};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font: "+this.fontSize+"px "+this.fontType+"; ";this.textUnderline&&!this.textOverline&&
(a+="text-decoration: underline; ");!this.textUnderline&&this.textOverline&&(a+="text-decoration: overline; ");this.textUnderline&&this.textOverline&&(a+="text-decoration: underline overline; ");this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: bold; ");!this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: bold; ");!this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: normal; ");
this.textColor&&(a+="color: "+this.textColor+"; ");return a+"'"};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,this.fontType,this.textItalic,this.textBold,this.textUnderline,this.textOverline,this.textColor)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,k,b,c,d,j,f,r,m,l,q,p,t;a.Space=function(b,c){this.parent=b;g=this.evaluator=this.parent.evaluator;k=g.parser;this.id="";this.values=c;this.type="R2";this.xExpr=k.parse("0");this.yExpr=
k.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=k.parse("1");this.fixed=2!=b.version?!1:!0;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";this.bg_display="topleft";this.background="descinst.com.mja.descartes.DescartesJS.class"===b.code||b.arquimedes?new a.Color("f0f8fa"):new a.Color("ffffff");this.net=2!=b.version?new a.Color("c0c0c0"):"";this.net10=2!=b.version?new a.Color("808080"):
"";this.axes=2!=b.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.x_axis=2!=b.version?"":" ";this.y_axis=2!=b.version?"":" ";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=0;this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backgroundGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var d in c)c.hasOwnProperty(d)&&
(this[d]=c[d]);this.init()};a.Space.prototype.init=function(){e=this.parent;g=this.evaluator;b=this.id;this.displaceRegionNorth=e.displaceRegionNorth||0;this.displaceRegionWest=e.displaceRegionWest||0;void 0!=this.wExpr&&(this.w=(parseInt(e.container.width)-this.displaceRegionWest)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=(parseInt(e.container.height)-this.displaceRegionNorth)*parseFloat(this.hExpr)/100);j=parseInt(e.container.height);f=parseInt(e.container.width);this.x=g.evalExpression(this.xExpr)+
this.displaceRegionWest;this.y=g.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+"px",this.container.style.top=this.y+"px");0<=this.y?(c=j-this.y,this.h>c&&(this.h=c)):(c=this.h+this.y,this.h=c>=j?j:c);0<=this.x?(d=f-this.x,this.w>d&&(this.w=d)):(d=this.w+this.x,this.w=d>=f?f:d);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=e.getImage(this.imageSrc);this.OxExpr&&(m=this.OxExpr,"%"===m[m.length-
1]?this.Ox=this.w*parseFloat(m)/100:(r=parseFloat(m),r!=m&&(r=0),this.Ox=r));this.OyExpr&&(l=this.OyExpr,"%"===l[l.length-1]?this.Oy=this.h*parseFloat(l)/100:(r=parseFloat(l),r!=l&&(r=0),this.Oy=r));""!==this.id&&2!==e.version?(g.setVariable(b+"._w",this.w),g.setVariable(b+"._h",this.h),g.setVariable(b+".escala",this.scale),g.setVariable(b+".Ox",this.Ox),g.setVariable(b+".Oy",this.Oy),g.setVariable(b+".mouse_x",0),g.setVariable(b+".mouse_y",0),g.setVariable(b+".mouse_pressed",0),g.setVariable(b+".mouse_clicked",
0),g.setVariable(b+".clic_izquierdo",0)):(r=g.getVariable("_w"),void 0===r&&(r=this.w),g.setVariable("_w",r),r=g.getVariable("_h"),void 0===r&&(r=this.h),g.setVariable("_h",r),r=g.getVariable("escala"),void 0===r&&(r=this.scale),g.setVariable("escala",r),r=g.getVariable("Ox"),void 0===r&&(r=this.Ox),g.setVariable("Ox",r),r=g.getVariable("Oy"),void 0===r&&(r=this.Oy),g.setVariable("Oy",r),g.setVariable("mouse_x",0),g.setVariable("mouse_y",0),g.setVariable("mouse_pressed",0),g.setVariable("mouse_clicked",
0),g.setVariable("clic_izquierdo",0),""===this.x_axis&&(""===this.y_axis&&2==e.version)&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a){a.background&&"R3"!==this.type?this.backgroundGraphics.push(a):this.graphics.push(a)};a.Space.prototype.getRelativeX=function(a){return(parseInt(a)-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-parseInt(a)+
this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};a.Space.prototype.findOffset=function(){q=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(p=this.container.style.display);this.container.style.display="block";if(q.getBoundingClientRect){var a=q.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;q;)q.tagName&&
"html"!==q.tagName.toLowerCase()?(this.offsetLeft+=q.offsetLeft||0,this.offsetTop+=q.offsetTop||0,q=q.parentNode):q=null;this.container&&this.container.style&&(this.container.style.display=p)};a.Space.prototype.getCursorPosition=function(b){t=a.getCursorPosition(b);return{x:t.x-this.offsetLeft,y:t.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){var e,g;if(a.loadLib)return a;var k=Math.floor,b=Math.round,c=2*Math.PI,d=a.convertFont("SansSerif,PLAIN,12"),j=a.convertFont("Monospaced,PLAIN,12"),
f,r,m,l,q,p,t,n,u,h,s,v,y,B,x,D,C,A,z,G,F,H,J,w,I,E,O,P,L;a.Space2D=function(b,c){a.Space.call(this,b,c);f=this;f.backgroundCanvas=document.createElement("canvas");f.backgroundCanvas.setAttribute("id",f.id+"_background");f.backgroundCanvas.setAttribute("width",f.w+"px");f.backgroundCanvas.setAttribute("height",f.h+"px");f.backgroundCtx=f.backgroundCanvas.getContext("2d");f.backgroundCtx.imageSmoothingEnabled=!1;f.backgroundCtx.mozImageSmoothingEnabled=!1;f.backgroundCtx.webkitImageSmoothingEnabled=
!1;f.canvas=document.createElement("canvas");f.canvas.setAttribute("id",f.id+"_canvas");f.canvas.setAttribute("width",f.w+"px");f.canvas.setAttribute("height",f.h+"px");f.canvas.setAttribute("class","DescartesSpace2DCanvas");f.canvas.setAttribute("style","z-index: "+f.zIndex+";");f.ctx=f.canvas.getContext("2d");f.ctx.imageSmoothingEnabled=!1;f.ctx.mozImageSmoothingEnabled=!1;f.ctx.webkitImageSmoothingEnabled=!1;f.graphicControlContainer=document.createElement("div");f.graphicControlContainer.setAttribute("id",
f.id+"_graphicControls");f.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+f.zIndex+";");f.numericalControlContainer=document.createElement("div");f.numericalControlContainer.setAttribute("id",f.id+"_numericalControls");f.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+f.zIndex+";");f.container=document.createElement("div");f.container.setAttribute("id",f.id);f.container.setAttribute("class","DescartesSpace2DContainer");
f.container.setAttribute("style","left: "+f.x+"px; top: "+f.y+"px; z-index: "+f.zIndex+";");f.parent.arquimedes&&"#f0f8fa"===f.background.getColor()&&(f.container.style.border="1px solid #b8c4c8");f.container.appendChild(f.backgroundCanvas);f.container.appendChild(f.canvas);f.container.appendChild(f.graphicControlContainer);f.container.appendChild(f.numericalControlContainer);b.container.insertBefore(f.container,b.loader);f.parent.images[f.id+".image"]=f.canvas;f.parent.images[f.id+".image"].ready=
1;f.parent.images[f.id+".image"].complete=!0;f.evaluator.setVariable(f.id+".image",f.id+".image");f.parent.images[f.id+".back"]=f.backgroundCanvas;f.parent.images[f.id+".back"].ready=1;f.parent.images[f.id+".back"].complete=!0;f.evaluator.setVariable(f.id+".back",f.id+".back");""!==f.id&&2!==b.version?(f.OxString=f.id+".Ox",f.OyString=f.id+".Oy",f.scaleString=f.id+".escala",f.wString=f.id+"._w",f.hString=f.id+"._h",f.mxString=f.id+".mouse_x",f.myString=f.id+".mouse_y",f.mpressedString=f.id+".mouse_pressed",
f.mclickedString=f.id+".mouse_clicked",f.mclicizquierdoString=f.id+".clic_izquierdo"):(f.OxString="Ox",f.OyString="Oy",f.scaleString="escala",f.wString="_w",f.hString="_h",f.mxString="mouse_x",f.myString="mouse_y",f.mpressedString="mouse_pressed",f.mclickedString="mouse_clicked",f.mclicizquierdoString="clic_izquierdo");"descartesJS_scenario"!==f.id&&f.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){f=this;f.uber.init.call(f);f.canvas&&(f.backgroundCanvas.setAttribute("width",
f.w+"px"),f.backgroundCanvas.setAttribute("height",f.h+"px"),f.canvas.setAttribute("width",f.w+"px"),f.canvas.setAttribute("height",f.h+"px"));f.container&&f.findOffset()};a.Space2D.prototype.update=function(a){f=this;r=f.evaluator;m=f.parent;r.setVariable(f.wString,f.w);r.setVariable(f.hString,f.h);f.drawIfValue=0<r.evalExpression(f.drawif);if(f.drawIfValue){q=f.x!==r.evalExpression(f.xExpr)+f.displaceRegionWest;p=f.y!==r.evalExpression(f.yExpr)+m.plecaHeight+f.displaceRegionNorth;f.spaceChange=
a||q||p||f.drawBefore!==f.drawIfValue||f.Ox!==r.getVariable(f.OxString)||f.Oy!==r.getVariable(f.OyString)||f.scale!==r.getVariable(f.scaleString);f.x=q?r.evalExpression(f.xExpr)+f.displaceRegionWest:f.x;f.y=p?r.evalExpression(f.yExpr)+m.plecaHeight+f.displaceRegionNorth:f.y;f.Ox=r.getVariable(f.OxString);f.Oy=r.getVariable(f.OyString);f.scale=r.getVariable(f.scaleString);f.drawBefore=f.drawIfValue;1E-6>f.scale?(f.scale=1E-6,r.setVariable(f.scaleString,1E-6)):1E6<f.scale&&(f.scale=1E6,r.setVariable(f.scaleString,
1E6));if(q||p)f.container.style.left=f.x+"px",f.container.style.top=f.y+"px",f.findOffset();f.container.style.display="block";f.drawTrace=!f.spaceChange&&!f.click;f.spaceChange&&f.drawBackground();f.draw()}else f.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){r=this.evaluator;l=this.backgroundCtx;l.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);l.fillStyle=this.background.getColor();l.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);
this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?l.drawImage(this.image,0,0):"stretch"===this.bg_display?l.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(l.fillStyle=l.createPattern(this.image,"repeat"),l.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&l.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));n=this.scale;u=0;for(h=0>this.w+this.h?0:this.w+this.h;n>h;)n/=
10,u++;for(;n<h/10;)n*=10;l.lineWidth=1;""!==this.net&&(l.strokeStyle=this.net.getColor(),this.drawMarks(l,n/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)l.strokeStyle=this.net10.getColor(),this.drawMarks(l,n,-1);if(""!==this.axes){l.strokeStyle=this.axes.getColor();l.beginPath();if(""!==this.x_axis||2!==this.parent.version)l.moveTo(0,k(this.h/2+this.Oy)+0.5),l.lineTo(this.w,k(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)l.moveTo(k(this.w/
2+this.Ox)+0.5,0),l.lineTo(k(this.w/2+this.Ox)+0.5,this.h);l.stroke();this.drawMarks(l,n,4);this.drawMarks(l,n/2,2);this.drawMarks(l,n/10,1)}if(""!==this.x_axis||""!==this.y_axis)l.fillStyle=""!==this.axes?this.axes.getColor():"black",l.font=d,l.textAlign="right",l.textBaseline="alphabetic",l.fillText(this.x_axis,k(this.w)-2,k(this.h/2+this.Oy)+12),l.fillText(this.y_axis,k(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(l.fillStyle=this.axes.getColor(),l.font=d,l.textAlign="start",l.textBaseline=
"bottom",n>(this.w+this.h)/2?this.drawNumbers(l,n/5,n<=this.scale?u+1:u):n>(this.w+this.h)/4?this.drawNumbers(l,n/2,n<=this.scale?u+1:u):this.drawNumbers(l,n,u));for(var a=0,b=this.backgroundGraphics.length;a<b;a++)this.backgroundGraphics[a].draw()};a.Space2D.prototype.draw=function(){l=this.ctx;l.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,b=this.graphics.length;a<b;a++)t=this.graphics[a],""!==t.trace&&this.drawTrace&&t.drawTrace(),t.draw();a=0;for(b=this.graphicsCtr.length;a<
b;a++)this.graphicsCtr[a].update(),this.graphicsCtr[a].draw();""!=this.text&&(this.click&&"L"===this.whichButton)&&(l.fillStyle=this.text.getColor(),l.strokeStyle=l.fillStyle,l.lineWidth=1,l.font=j,l.textAlign="center",l.textBaseline="alphabetic",F=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),H=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),J="("+F+","+H+")",w=k(l.measureText(J).width/2),I=this.getAbsoluteX(this.mouse_x),
E=this.getAbsoluteY(this.mouse_y),O=k(I),P=k(E-10),O+w>this.w?O=this.w-w:0>O-w&&(O=w),P+1>this.h?P=this.h:0>P-14&&(P=15),l.fillText(J,O,P),l.beginPath(),l.arc(I,E,2.5,0,c,!0),l.stroke())};a.Space2D.prototype.drawMarks=function(a,c,d){s=this.w;v=this.h;C=0;A=s;z=0;G=v;x=k(s/2+this.Ox);D=k(v/2+this.Oy);0<=d&&(C=x-d,A=x+d,z=D-d,G=D+d);a.beginPath();for(d=-b(x/c);(y=x+b(d*c))<s;d++)a.moveTo(y+0.5,z+0.5),a.lineTo(y+0.5,G+0.5);for(d=-b(D/c);(B=D+b(d*c))<v;d++)a.moveTo(C+0.5,B+0.5),a.lineTo(A+0.5,B+0.5);
a.stroke()};a.Space2D.prototype.drawNumbers=function(a,c){s=this.w;v=this.h;x=k(s/2+this.Ox);D=k(v/2+this.Oy);for(var d=-b(x/c);(y=x+b(d*c))<s;d++)a.fillText(parseFloat((d*c/this.scale).toFixed(4)),y+1,D-2);for(d=-b(D/c);(B=D+b(d*c))<v;d++)0!==parseFloat(-d*c/this.scale)&&a.fillText(parseFloat((-d*c/this.scale).toFixed(4)),x+5,B+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){m.click=1;m.evaluator.setVariable(m.mpressedString,1);m.evaluator.setVariable(m.mclickedString,
0);m.evaluator.setVariable(m.mclicizquierdoString,0);m.parent.deactivateGraphiControls();j(a);window.addEventListener("touchmove",l);window.addEventListener("touchend",c);a.preventDefault()}function c(a){m.click=0;m.evaluator.setVariable(m.mpressedString,0);m.evaluator.setVariable(m.mclickedString,1);m.evaluator.setVariable(m.mclicizquierdoString,1);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",c,!1);a.preventDefault();m.parent.update()}function d(b){m.click=1;
m.parent.deactivateGraphiControls();m.whichButton=a.whichButton(b);"R"===m.whichButton&&(window.addEventListener("mouseup",f),m.fixed||(m.clickPosForZoom=m.getCursorPosition(b).y,m.tempScale=m.scale,window.addEventListener("mousemove",h)));"L"===m.whichButton&&(m.evaluator.setVariable(m.mpressedString,1),m.evaluator.setVariable(m.mclickedString,0),m.evaluator.setVariable(m.mclicizquierdoString,0),j(b),window.addEventListener("mousemove",l),window.addEventListener("mouseup",f));b.preventDefault()}
function f(a){m.click=0;m.evaluator.setVariable(m.mpressedString,0);m.evaluator.setVariable(m.mclickedString,1);m.evaluator.setVariable(m.mclicizquierdoString,1);a.preventDefault();"R"===m.whichButton&&window.removeEventListener("mousemove",h,!1);window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",f,!1);m.parent.update()}function j(a){m.posAnte=m.getCursorPosition(a);m.mouse_x=m.getRelativeX(m.posAnte.x);m.mouse_y=m.getRelativeY(m.posAnte.y);m.evaluator.setVariable(m.mxString,
m.mouse_x);m.evaluator.setVariable(m.myString,m.mouse_y);m.evaluator.setVariable(m.mclickedString,0);m.evaluator.setVariable(m.mclicizquierdoString,0);m.parent.update()}function h(a){a.preventDefault();m.clickPosForZoomNew=m.getCursorPosition(a).y;m.evaluator.setVariable(m.scaleString,m.tempScale+m.tempScale/45*((m.clickPosForZoom-m.clickPosForZoomNew)/10));m.parent.update()}function l(a){m.fixed||(m.posNext=m.getCursorPosition(a),e=k(m.posAnte.x-m.posNext.x),g=k(m.posAnte.y-m.posNext.y),m.evaluator.setVariable(m.OxString,
m.Ox-e),m.evaluator.setVariable(m.OyString,m.Oy-g),m.posAnte.x-=e,m.posAnte.y-=g);j(a);a.preventDefault()}var m=this;L=a.hasTouchSupport;m.canvas.oncontextmenu=function(){return!1};L&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",j),this.canvas.addEventListener("touchstart",b));L||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",j),this.canvas.addEventListener("mousedown",d))};return a}(descartesJS||{}),descartesJS=function(a){var e,g,k;function b(a,
b){return b.depth-a.depth}function c(b,c){X=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));U=a.add3D(b,a.scalarProduct3D(X,-2));V=a.norm3D(U);return 0!==V?a.scalarProduct3D(U,1/V):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var d=Math.floor,j=Math.round,f=Math.max,r=Math.cos,m=Math.sin,l=Math.sqrt,q=15*Math.PI/180,p=Math.cos(q),t=Math.sin(q),n,u,h,s,v,y,B,x,D,C,A,z,G,F,H,J,w,I,E,O,P,L,Q,R=[],M,N,K,T,S,W,X,U,V;a.Space3D=function(b,c){a.Space.call(this,b,c);h=this;h.backgroundCanvas=document.createElement("canvas");
h.backgroundCanvas.setAttribute("id",h.id+"_background");h.backgroundCanvas.setAttribute("width",h.w+"px");h.backgroundCanvas.setAttribute("height",h.h+"px");h.canvas=document.createElement("canvas");h.canvas.setAttribute("id",h.id+"_canvas");h.canvas.setAttribute("width",h.w+"px");h.canvas.setAttribute("height",h.h+"px");h.canvas.setAttribute("class","DescartesSpace3DCanvas");h.canvas.setAttribute("style","z-index: "+h.zIndex+";");h.ctx=h.canvas.getContext("2d");h.ctx.imageSmoothingEnabled=!1;h.ctx.mozImageSmoothingEnabled=
!1;h.ctx.webkitImageSmoothingEnabled=!1;h.graphicControlContainer=document.createElement("div");h.graphicControlContainer.setAttribute("id",h.id+"_graphicControls");h.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+h.zIndex+";");h.numericalControlContainer=document.createElement("div");h.numericalControlContainer.setAttribute("id",h.id+"_numericalControls");h.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+
h.zIndex+";");h.container=document.createElement("div");h.container.setAttribute("id",h.id);h.container.setAttribute("class","DescartesSpace3DContainer");h.container.setAttribute("style","left: "+h.x+"px; top: "+h.y+"px; z-index: "+h.zIndex+";");h.container.appendChild(h.backgroundCanvas);h.container.appendChild(h.canvas);h.container.appendChild(h.graphicControlContainer);h.container.appendChild(h.numericalControlContainer);b.container.insertBefore(h.container,b.loader);h.eye={x:0,y:0,z:0};h.lights=
[{x:50,y:50,z:70},{x:50,y:-50,z:30},{x:20,y:0,z:-80},{x:0,y:0,z:0}];for(var d=0,f=h.lights.length;d<f;d++)h.lights[d]=a.normalize3D(h.lights[d]);h.light3={x:0,y:0,z:0};h.intensity=[0.4,0.5,0.3,0];h.userIntensity=0;h.dim=1;h.tmpIntensity=[];h.OxStr=h.id+".Ox";h.OyStr=h.id+".Oy";h.scaleStr=h.id+".escala";h.wStr=h.id+"._w";h.hStr=h.id+"._h";h.obsStr=h.id+".observador";h.rotZStr=h.id+".rot.z";h.rotYStr=h.id+".rot.y";h.userI_Dim_Str=h.id+".userIlum.dim";h.userI_I_Str=h.id+".userIlum.I";h.userI_x_Str=h.id+
".userIlum.x";h.userI_y_Str=h.id+".userIlum.y";h.userI_z_Str=h.id+".userIlum.z";h.evaluator.setVariable(h.rotZStr,0);h.evaluator.setVariable(h.rotYStr,0);h.evaluator.setVariable(h.userI_Dim_Str,h.dim);h.evaluator.setVariable(h.userI_I_Str,h.userIntensity);h.evaluator.setVariable(h.userI_x_Str,0);h.evaluator.setVariable(h.userI_y_Str,0);h.evaluator.setVariable(h.userI_z_Str,0);h.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(){h=this;h.uber.init.call(h);
h.canvas&&(h.canvas.setAttribute("width",h.w+"px"),h.canvas.setAttribute("height",h.h+"px"));h.container&&h.findOffset();h.w_2=h.w/2;h.h_2=h.h/2;h.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){h=this;n=h.evaluator;u=h.parent;n.setVariable(h.wStr,h.w);n.setVariable(h.hStr,h.h);h.drawIfValue=0<n.evalExpression(h.drawif);if(h.drawIfValue){D=h.x!==n.evalExpression(h.xExpr)+h.displaceRegionWest;C=h.y!==n.evalExpression(h.yExpr)+u.plecaHeight+h.displaceRegionNorth;h.spaceChange=a||D||C||h.drawBefore!==
h.drawIfValue||h.Ox!==n.getVariable(h.OxStr)||h.Oy!==n.getVariable(h.OyStr)||h.scale!==n.getVariable(h.scaleStr);h.x=D?n.evalExpression(h.xExpr)+h.displaceRegionWest:h.x;h.y=C?n.evalExpression(h.yExpr)+u.plecaHeight+h.displaceRegionNorth:h.y;h.Ox=n.getVariable(h.OxStr);h.Oy=n.getVariable(h.OyStr);h.scale=n.getVariable(h.scaleStr);h.drawBefore=h.drawIfValue;if(a||void 0==h.observer){var b;a=0;for(var c=h.parent.controls.length;a<c;a++)h.parent.controls[a].id===h.obsStr&&(b=!0);h.observer=b?n.getVariable(h.obsStr)||
0.5*(h.w+h.h):2.5*(h.w+h.h);h.observer=f(h.observer,0.1*(h.w+h.h));n.setVariable(h.obsStr,h.observer);h.eye={x:h.observer/h.scale*p,y:0,z:h.observer/h.scale*t};h.D=h.scale*h.eye.x/p;h.XE=j(h.scale*h.eye.y+0.5);h.YE=j(h.scale*h.eye.z+0.5)}h.observer=f(n.getVariable(h.obsStr),0.1*(h.w+h.h));n.setVariable(h.obsStr,h.observer);1E-6>h.scale?(h.scale=1E-6,n.setVariable(h.scaleStr,1E-6)):1E6<h.scale&&(h.scale=1E6,n.setVariable(h.scaleStr,1E6));if(D||C)h.container.style.left=h.x+"px",h.container.style.top=
h.y+"px",h.findOffset();h.container.style.display="block";h.dim=n.getVariable(h.userI_Dim_Str);h.userIntensity=n.getVariable(h.userI_I_Str);h.light3={x:parseInt(n.getVariable(h.userI_x_Str)),y:parseInt(n.getVariable(h.userI_y_Str)),z:parseInt(n.getVariable(h.userI_z_Str))};h.updateCamera();h.draw()}else h.container.style.display="none"};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,
0,this.canvas.width,this.canvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?this.ctx.drawImage(this.image,0,0):"stretch"===this.bg_display?this.ctx.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/
2));for(var a=0,c=this.graphics.length;a<c;a++)s=this.graphics[a],s.update();this.primitives=[];a=0;for(c=this.graphics.length;a<c;a++){s=this.graphics[a];if(s.split||this.split)for(var d=a+1;d<c;d++)v=this.graphics[d],(v.split||this.split)&&s.splitFace(v);this.primitives=this.primitives.concat(s.primitives||[])}y=this.primitives;B=y.length;for(a=0;a<B;a++)y[a].computeDepth(this);y=y.sort(b);for(a=0;a<B;a++)y[a].draw(this.ctx,this);a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};
a.Space3D.prototype.updateCamera=function(){h=this;h.D=h.observer;h.eye.x=h.D/h.scale;h.eye.y=h.XE/h.scale;h.eye.z=h.YE/h.scale};a.Space3D.prototype.rotateVertex=function(b){w=a.degToRad(h.evaluator.getVariable(h.rotZStr));I=r(w);E=m(w);e=b.x*I-b.y*E;g=b.x*E+b.y*I;k=b.z;w=a.degToRad(h.evaluator.getVariable(h.rotYStr));I=r(w);E=m(w);return{x:k*E+e*I,y:g,z:k*I-e*E}};a.Space3D.prototype.project=function(a){h=this;G=h.eye.x-a.x;F=h.eye.y-a.y;H=h.eye.z-a.z;J=-a.x/l(G*G+F*F+H*H)||0;G=h.scale*(a.y+J*(h.eye.y-
a.y));F=-h.scale*(a.z+J*(h.eye.z-a.z));return{x:parseInt(G+this.w_2+this.Ox),y:parseInt(F+this.h_2+this.Oy),z:J}};a.Space3D.prototype.computeColor=function(b,f,e){T=a.subtract3D(this.eye,f.average);S=a.norm3D(T);W=a.scalarProduct3D(T,1/S);this.lights[3]=a.subtract3D(this.light3,f.average);Q=a.norm3D(this.lights[3]);for(var k=0,j=this.intensity.length-1;k<j;k++)R[k]=this.intensity[k]*this.dim;R[3]=this.userIntensity*this.userIntensity/Q||0;M=e?this.dim/2:this.dim/4;N=0;K=0<=f.direction?f.normal:a.scalarProduct3D(f.normal,
-1);k=0;for(j=this.lights.length;k<j;k++)e?(N=Math.max(0,a.dotProduct3D(c(this.lights[k],K),W)),N*=N*N):N=Math.max(0,a.dotProduct3D(this.lights[k],K)),M+=R[k]*N;M=Math.min(M,1);O=d(b.r*M);P=d(b.g*M);L=d(b.b*M);return"rgba("+O+","+P+","+L+","+b.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function b(a){g.click=1;g.evaluator.setVariable(g.id+".mouse_pressed",1);g.parent.deactivateGraphiControls();g.posAnte=g.getCursorPosition(a);g.oldMouse.x=g.getRelativeX(g.posAnte.x);g.oldMouse.y=
g.getRelativeY(g.posAnte.y);e(a);window.addEventListener("touchmove",h);window.addEventListener("touchend",c);a.preventDefault()}function c(a){g.click=0;g.evaluator.setVariable(g.id+".mouse_pressed",0);window.removeEventListener("touchmove",h,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}function d(b){g.click=1;g.parent.deactivateGraphiControls();g.whichButton=a.whichButton(b);"R"===g.whichButton?(window.addEventListener("mouseup",f),g.fixed||(g.clickPosForZoom=g.getCursorPosition(b).y,
g.tempScale=g.scale,window.addEventListener("mousemove",k))):"L"==g.whichButton&&(g.evaluator.setVariable(g.id+".mouse_pressed",1),g.posAnte=g.getCursorPosition(b),g.oldMouse.x=g.getRelativeX(g.posAnte.x),g.oldMouse.y=g.getRelativeY(g.posAnte.y),e(b),window.addEventListener("mousemove",h),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){g.click=0;g.evaluator.setVariable(g.id+".mouse_pressed",0);a.preventDefault();"R"===g.whichButton&&window.removeEventListener("mousemove",k,
!1);window.removeEventListener("mousemove",h,!1);window.removeEventListener("mouseup",f,!1)}function e(a){g.posAnte=g.getCursorPosition(a);g.mouse_x=g.getRelativeX(g.posAnte.x);g.mouse_y=g.getRelativeY(g.posAnte.y);g.evaluator.setVariable(g.id+".mouse_x",g.mouse_x);g.evaluator.setVariable(g.id+".mouse_y",g.mouse_y);g.parent.update()}function k(a){a.preventDefault();g.clickPosForZoomNew=g.getCursorPosition(a).y;g.evaluator.setVariable(g.scaleStr,g.tempScale+g.tempScale/45*((g.clickPosForZoom-g.clickPosForZoomNew)/
10));g.parent.update()}function h(b){if(!g.fixed&&g.click){A=parseInt(50*(g.oldMouse.x-g.mouse_x));z=parseInt(50*(g.oldMouse.y-g.mouse_y));if(A!==g.disp.x||z!==g.disp.y)g.alpha=a.degToRad(g.evaluator.getVariable(g.rotZStr)),g.beta=a.degToRad(-g.evaluator.getVariable(g.rotYStr)),g.alpha=j(a.radToDeg(g.alpha)-A),g.beta=j(a.radToDeg(g.beta)-z),g.evaluator.setVariable(g.rotZStr,g.alpha),g.evaluator.setVariable(g.rotYStr,-g.beta),g.disp.x=A,g.disp.y=z,g.oldMouse.x=g.getRelativeX(g.posAnte.x),g.oldMouse.y=
g.getRelativeY(g.posAnte.y);e(b);b.preventDefault()}}var g=this;x=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};x&&this.canvas.addEventListener("touchstart",b);x||this.canvas.addEventListener("mousedown",d);this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.SpaceAP=function(g,k){a.Space.call(this,g,k);this.exportarVars=this.importarVars=null;e=g.evaluator;this.file=this.file.match(/^\[/)&&this.file.match(/\]$/)?e.parser.parse(this.file.substring(1,
this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?e.parser.parse(this.file):e.parser.parse("'"+this.file+"'");this.oldFile=e.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var e;if(this.oldFile){var k=document.getElementById(this.oldFile);e=k&&"descartes/spaceApFile"==k.type?k.text:a.openExternalFile(this.oldFile);null!=e&&(e=e.split("\n"))}if(e&&e.toString().match(/<applet/gi)){for(var k="",b=!1,
c=0,d=e.length;c<d&&!(e[c].match("<applet")&&(b=!0),b&&(k+=e[c]),e[c].match("</applet"));c++);c=document.createElement("div");c.innerHTML=k;c.firstChild.setAttribute("width",this.w);c.firstChild.setAttribute("height",this.h);k=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(c.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+this.background+
"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");k?this.parent.container.replaceChild(this.descApp.container,k):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);k=this.descApp.spaces;c=0;for(d=k.length;c<d;c++)k[c].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var j=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();
this.updateControls();this.updateSpaces();j.exportar()}}else k=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),c="position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";",this.image&&("topleft"==this.bg_display?c+="background-image: url("+this.imageSrc+
"); background-repeat:no-repeat;":"stretch"==this.bg_display?c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?c+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",c),k?this.parent.container.replaceChild(this.descApp.container,k):this.parent.container.insertBefore(this.descApp.container,
this.parent.loader),this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.evalExpression(this.file);if(this.oldFile!=a)this.oldFile=a,this.initFile();else{var a=this.x!=this.evaluator.evalExpression(this.xExpr),e=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=e?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:
this.y;a&&(this.descApp.container.style.left=this.x+"px");e&&(this.descApp.container.style.top=this.y+"px");if(a||e)for(var a=this.descApp.spaces,e=0,b=a.length;e<b;e++)a[e].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.importarVars)){this.importarVars=[];for(var c in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(c)&&c.match(/^public./)&&this.importarVars.push({varName:c,
value:this.evaluator.getVariable(c)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,e=!1,b=0,c=this.importarVars.length;b<c;b++)a=this.evaluator.getVariable(this.importarVars[b].varName),a!=this.importarVars[b].value&&(this.importarVars[b].value=a,this.descApp.evaluator.setVariable(this.importarVars[b].varName,this.importarVars[b].value),e=!0);e&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e,g,k,b;a.SpaceHTML_IFrame=function(b,d){a.Space.call(this,b,d);var e=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file=this.file.match(/^\[/)&&this.file.match(/\]$/)?e.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?e.parser.parse(this.file):e.parser.parse("'"+this.file+"'");this.oldFile=e.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 f=this;this.MyIFrame.onload=
function(){var a=this;f.evaluator.setFunction(f.id+".set",function(b,c){a.contentWindow.postMessage({type:"set",name:b,value:c},"*")});f.evaluator.setFunction(f.id+".update",function(){a.contentWindow.postMessage({type:"update"},"*")});f.evaluator.setFunction(f.id+".exec",function(b,c){a.contentWindow.postMessage({type:"exec",name:b,value:c},"*")})};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=
function(){self=this;self.uber.init.call(self);self.MyIFrame&&(self.MyIFrame.style.width=self.w+"px",self.MyIFrame.style.height=self.h+"px",self.MyIFrame.style.left=self.x+"px",self.MyIFrame.style.top=self.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){e=this.evaluator;this.drawIfValue=0<e.evalExpression(this.drawif);if(this.drawif){this.MyIFrame.style.display=this.drawIfValue?"block":"none";a&&(this.y=this.x=Math.Infinity);g=this.x!==e.evalExpression(this.xExpr)+this.displaceRegionWest;
k=this.y!==e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=g?e.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=k?e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(g||k)this.MyIFrame.style.left=this.x+"px",this.MyIFrame.style.top=this.y+"px";b=e.evalExpression(this.file);b!==this.oldFile&&(this.oldFile=b,this.MyIFrame.setAttribute("src",b));this.scrollVar=e.getVariable(this.id+"._scroll");1==this.scrollVar?
(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=""):-1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.DescartesLoader=function(a){this.children=a.children;this.lessonParser=a.lessonParser;this.images=a.images;this.images.length=a.images.length;this.audios=
a.audios;this.audios.length=a.audios.length;this.arquimedes=a.arquimedes;this.descartesApp=a;var b;if(a.image_loader)b=a.image_loader;else{b=a.loader.width;var c=a.loader.height,k=document.createElement("canvas");k.width=b;k.height=c;var g=k.getContext("2d");g.save();g.strokeStyle="#1f375d";g.fillStyle="#1f375d";g.lineCap="round";g.lineWidth=2;g.beginPath();e=b<c?b/360:c/195;e=2.5<e?2.5:e;g.translate((b-120*e)/2,(c-65*e)/2);g.scale(e,e);g.moveTo(3,25);g.lineTo(3,1);g.lineTo(21,1);g.bezierCurveTo(33,
1,41,15,41,25);g.stroke();g.beginPath();g.moveTo(1,63);g.lineTo(1,64);g.moveTo(5,62);g.lineTo(5,64);g.moveTo(9,61);g.lineTo(9,64);g.moveTo(13,60);g.lineTo(13,64);g.moveTo(17,58);g.lineTo(17,64);g.moveTo(21,56);g.lineTo(21,64);g.moveTo(25,53);g.lineTo(25,64);g.moveTo(29,50);g.lineTo(29,64);g.moveTo(33,46);g.lineTo(33,64);g.moveTo(37,41);g.lineTo(37,64);g.moveTo(41,32);g.lineTo(41,64);g.stroke();g.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";g.fillText("escartes",45,33);g.fillText("JS",98,
64);g.restore();b=k.toDataURL()}this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+b+"); width: "+a.width+"px; height: "+a.height+"px;");a.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=a.width;this.loaderBar.height=a.height;this.loaderBar.setAttribute("class",
"DescartesLoaderBar");this.loaderBar.setAttribute("style","width: "+a.width+"px; height:"+a.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");a.loader.appendChild(this.loaderBar);this.barWidth=Math.floor(80);this.barHeight=Math.floor(a.loader.height/70);var l=this;this.timer=setInterval(function(){l.drawLoaderBar(l.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,c=this.images,f=this.audios,
e=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,k=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;this.arquimedes&&(c["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),c["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1}),c["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var g,q,p,t,n,u;p=0;for(n=b.length;p<n;p++)if("rtf"!==b[p].name){if(b[p].value.match(/'macro'|'makro'/g)){g="";var h;
q=this.lessonParser.split(b[p].value);u=0;for(var s=q.length;u<s;u++)"expresion"===babel[q[u][0]]&&(g=q[u][1]);g&&((h=document.getElementById(g))&&"descartes/macro"==h.type?h=h.text:(h=a.openExternalFile(g))&&!h.match(/tipo_de_macro/g)&&(h=null));if(h&&(g=h.match(e)))for(u=g.length;t<u;t++)q=g[t],!q.toLowerCase().match(/vacio.gif$/)&&""!=q.substring(0,q.length-4)&&(c[q]=new Image,c[q].addEventListener("load",function(){this.ready=1}),c[q].addEventListener("error",function(){this.errorload=1}),c[q].src=
q)}if(g=b[p].value.match(e)){t=0;for(u=g.length;t<u;t++)q=g[t],!q.toLowerCase().match(/vacio.gif$/)&&""!=q.substring(0,q.length-4)&&(c[q]=new Image,c[q].addEventListener("load",function(){this.ready=1}),c[q].addEventListener("error",function(){this.errorload=1}),c[q].src=q)}if(g=b[p].value.match(k)){t=0;for(q=g.length;t<q;t++)this.initAudio(g[t])}}for(var v in c)c.hasOwnProperty(v)&&this.images.length++;for(v in f)f.hasOwnProperty(v)&&this.audios.length++;var y=this,B=this.images.length+this.audios.length,
x=function(){y.readys=0;for(var a in c)c.hasOwnProperty(a)&&(c[a].ready||c[a].errorload)&&y.readys++;for(a in y.audios)f.hasOwnProperty(a)&&(f[a].ready||f[a].errorload)&&y.readys++;y.readys!=B?setTimeout(x,30):(clearTimeout(y.timer),y.descartesApp.initBuildApp())};x()};a.DescartesLoader.prototype.initAudio=function(b){var c=this.audios;c[b]=new Audio(b);c[b].filename=b;var f=function(){this.ready=1},e=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-
3)?(c[b]=new Audio(this.filename.replace("mp3","ogg")),c[b].filename=this.filename.replace("mp3","ogg"),c[b].addEventListener("canplaythrough",f),c[b].addEventListener("load",f),c[b].addEventListener("error",e),c[b].load()):(console.log("El archivo '"+b+"' no puede ser reproducido"),this.errorload=1)};c[b].addEventListener("canplaythrough",f);c[b].addEventListener("load",f);c[b].addEventListener("error",e);a.hasTouchSupport?(c[b].load(),c[b].play(),c[b].ready=1):c[b].load()};var g,k,b,c;a.DescartesLoader.prototype.drawLoaderBar=
function(a,j,f){g=this.barWidth;k=this.barHeight;b=this.images.length+this.audios.length;c=2*(g-2)/b;a.translate(j/2,(f-65*e)/2+90*e);a.scale(e,e);a.strokeRect(-g,-k,2*g,k);a.fillStyle="gray";a.fillRect(-g+2,-k+2,2*(g-2),k-4);a.fillStyle="#1f375d";a.fillRect(-g+2,-k+2,this.readys*c,k-4);a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var b="[",c=0,d=a.length;c<d;c++){if(a[c]instanceof Array)b+=e(a[c]);else{g=a[c];if("undefined"==typeof g||!g)g=0;"string"==
typeof g&&(g="'"+g+"'");b+=g}c<d-1&&(b+=",")}return b+"]"}if(a.loadLib)return a;a.DescartesApp=function(a){this.applet=a;this.parentContainer=a.parentNode;this.width=parseFloat(a.getAttribute("width"));this.height=parseFloat(a.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");this.children=a.getElementsByTagName("param");this.code=a.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=
-1;this.firstRun=!0;this.init()};a.DescartesApp.prototype.init=function(){this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class","i")||!!this.code.match("Arquimedes","i")||!!this.code.match("Discurso","i");this.licenseA="{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto del  {\\*\\hyperlink Ministerio de Educaci\u00f3n de Espa\u00f1a|http://recursostic.educacion.es/descartes/web/DescartesWeb2.0/} y\\par                                        el {\\*\\hyperlink Instituto de Matem\u00e1ticas|http://arquimedes.matem.unam.mx/} de la Universidad Nacional Aut\u00f3noma de M\u00e9xico, cedido bajo licencia {\\*\\hyperlink EUPL v 1.1|/resources/eupl_v1.1es.pdf}, con {\\*\\hyperlink c\u00f3digo en Java|http://recursostic.educacion.es/descartes/web/source/}.}";
for(var e=this.children,b,c=0,d=0,g=0,f=e.length;g<f;g++)b=e[g],"rtf_height"==b.name&&(c=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),d=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&c&&(this.height=c+d+90);this.spaces=[];this.externalSpace={container:document.createElement("div"),controls:[]};this.northSpace={container:document.createElement("div"),controls:[]};this.southSpace={container:document.createElement("div"),
controls:[]};this.eastSpace={container:document.createElement("div"),controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.specialSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};this.controls=[];this.auxiliaries=[];this.events=[];this.cacheVars={};this.getVarsNames={};this.numberOfIframes=this.plecaHeight=this.tabindex=this.zIndex=0;void 0!=this.container&&this.parentContainer.removeChild(this.container);
this.container=document.createElement("div");this.loader=document.createElement("div");this.parentContainer.appendChild(this.container);this.container.width=this.width;this.container.height=this.height;this.container.setAttribute("class","DescartesAppContainer");this.container.setAttribute("style","width:"+this.width+"px; height:"+this.height+"px;");this.container.appendChild(this.loader);this.loader.width=this.width;this.loader.height=this.height;this.loader.setAttribute("class","DescartesLoader");
this.loader.setAttribute("style","width:"+this.width+"px; height:"+this.height+"px; z-index:1000;");this.firstRun?this.descartesLoader=new a.DescartesLoader(this):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){for(var a=this.children,b=this.lessonParser,c=[],d=[],e=[],f=[],g=[],m=[],l,q=0,p=a.length;q<p;q++)if(l=a[q],"pleca"==l.name)l=b.parsePleca(l.value,this.width),this.container.insertBefore(l,this.loader),this.plecaHeight=l.imageHeight?l.imageHeight:l.offsetHeight;else if("Buttons"==
babel[l.name])this.buttonsConfig=b.parseButtonsConfig(l.value);else if("decimal_symbol"==babel[l.name])this.decimal_symbol=l.value,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[l.name])this.version=parseInt(l.value);else if("language"==babel[l.name])this.language=l.value;else if("rtf"==l.name){var t=(this.width-780)/2,n=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;f.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
l.value.replace(/'/g,"&squot;")+"'");f.push("space='descartesJS_scenario' type='text' expresion='["+t+","+(n-25)+"]' background='yes' text='"+this.licenseA+"'");f.push("space='descartesJS_scenario' type='image' expresion='["+(t+15)+","+n+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==l.name.charAt(0)?(l.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,c.push(l.value)):"C"==l.name.charAt(0)&&"_"==l.name.charAt(1)?d.push(l.value):"A"==l.name.charAt(0)&&"_"==l.name.charAt(1)?
e.push(l.value):"G"==l.name.charAt(0)?f.push(l.value):"S"==l.name.charAt(0)?g.push(l.value):"Animation"==babel[l.name]&&m.push(l.value);this.scenarioRegion={container:document.createElement("div"),scroll:0};this.scenarioRegion.container.setAttribute("id","descartesJS_Scenario_Region");this.scenarioRegion.scenarioSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_scenario' fondo='blanco' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+this.width+"' alto='"+this.height+
"'");this.scenarioRegion.container.appendChild(this.scenarioRegion.scenarioSpace.container);this.arquimedes&&(this.container.appendChild(this.scenarioRegion.container),this.spaces.push(this.scenarioRegion.scenarioSpace));q=0;for(p=c.length;q<p;q++)a=b.parseSpace(c[q]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;q=0;for(p=f.length;q<p;q++)if(c=b.parseGraphic(f[q]))c.visible&&(this.editableRegionVisible=!0),c.space.addGraph(c);q=0;for(p=
g.length;q<p;q++)(c=b.parse3DGraphic(g[q]))&&c.space.addGraph(c);q=0;for(p=d.length;q<p;q++)this.controls.push(b.parseControl(d[q]));q=0;for(p=e.length;q<p;q++)b.parseAuxiliar(e[q]);q=0;for(p=m.length;q<p;q++)this.animation=b.parseAnimation(m[q]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();q=0;for(p=this.controls.length;q<p;q++)this.controls[q].init();this.updateControls();this.updateSpaces(!0);var u=this;this.numberOfIframes?setTimeout(function(){u.finishInit()},300*this.numberOfIframes):
this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";window.parent!==window&&(this.parentContainer.style.margin="0px",this.parentContainer.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready"},"*"),a.onResize());if(window.opener){document.body.style.margin="0px";document.body.style.padding="0px";this.parentContainer.style.margin=
"0px";this.parentContainer.style.padding="0px";var e=parseInt(this.width)+20,b=parseInt(this.height)+80;window.moveTo((parseInt(screen.width)-e)/2,(parseInt(screen.height)-b)/2);window.resizeTo(e,b);a.onResize()}a.externalEvaluator=new a.Evaluator};a.DescartesApp.prototype.configRegions=function(){var e=this.evaluator.parser,b=this.buttonsConfig,c=this.container;if(2!=this.version)var d="15",g=100,f=100,r=100,m=100;else d="14",g=63,f=50,r=44,m=53;var l=0,q=0,p=0,t=p=0,n=0,u=0,h=0,s=0,u=this.northSpace.controls,
v=this.southSpace.controls,y=this.eastSpace.controls,B=this.westSpace.controls;if(0<b.rowsNorth||0<u.length||b.about||b.config){0>=b.rowsNorth?(l=b.height,b.rowsNorth=1):l=b.height*b.rowsNorth;n=this.northSpace.container;n.setAttribute("id","descartesJS_northRegion");n.setAttribute("style","width:"+c.width+"px; height:"+l+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");c.insertBefore(n,this.loader);var n=c.width,x=0;b.about&&(x=g,n-=x);b.config&&(n-=f);for(var D=Math.ceil(u.length/
b.rowsNorth),C=n/D,p=0,A=u.length;p<A;p++)u[p].expresion=e.parse("("+(x+C*(p%D))+","+b.height*Math.floor(p/D)+","+C+","+b.height+")"),u[p].drawif=e.parse("1"),u[p].init();b.about&&(p="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",(new a.Button(this,{region:"north",name:p,font_size:e.parse(d),expresion:e.parse("(0, 0, "+g+", "+l+")")})).update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:e.parse(d),action:"config",expresion:e.parse("("+
(n+g)+", 0, "+f+", "+l+")")})).update()}if(0<b.rowsSouth||0<v.length||b.init||b.clear){0>=b.rowsSouth?(q=b.height,b.rowsSouth=1):q=b.height*b.rowsSouth;u=c.width;x=0;b.init&&(x=r,u-=x);b.clear&&(u-=m);n=this.southSpace.container;n.setAttribute("id","descartesJS_southRegion");n.setAttribute("style","width:"+c.width+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(c.height-q)+"px; z-index:100;");c.insertBefore(n,this.loader);D=Math.ceil(v.length/b.rowsSouth);C=u/D;p=0;for(A=
v.length;p<A;p++)v[p].expresion=e.parse("("+(x+C*(p%D))+","+b.height*Math.floor(p/D)+","+C+","+b.height+")"),v[p].drawif=e.parse("1"),v[p].init();b.init&&(p="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":"inicio",(new a.Button(this,{region:"south",name:p,font_size:e.parse(d),action:"init",expresion:e.parse("(0, 0, "+r+", "+q+")")})).update());b.clear&&(p="espa\u00f1ol"==this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:p,
font_size:e.parse(d),action:"clear",expresion:e.parse("("+(u+r)+", 0, "+m+", "+q+")")})).update())}if(0<y.length){p=c.height-l-q;h=b.widthEast;n=this.eastSpace.container;n.setAttribute("id","descartesJS_eastRegion");n.setAttribute("style","width:"+h+"px; height:"+p+"px; background:#c0c0c0; position:absolute; left:"+(c.width-h)+"px; top:"+l+"px; z-index:100;");c.insertBefore(n,this.loader);p=0;for(A=y.length;p<A;p++)y[p].expresion=e.parse("(0,"+b.height*p+","+h+","+b.height+")"),y[p].drawif=e.parse("1"),
y[p].init()}if(0<B.length){p=c.height-l-q;s=b.widthWest;n=this.westSpace.container;n.setAttribute("id","descartesJS_westRegion");n.setAttribute("style","width: "+s+"px; height: "+p+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+l+"px; z-index: 100;");c.insertBefore(n,this.loader);p=0;for(A=B.length;p<A;p++)B[p].expresion=e.parse("(0,"+b.height*p+","+s+","+b.height+")"),B[p].drawif=e.parse("1"),B[p].init()}if(this.editableRegionVisible){t=b.height;n=this.editableRegion.container;n.setAttribute("id",
"descartesJS_editableRegion");n.setAttribute("style","width:"+c.width+"px; height:"+t+"px; position:absolute; left:0px; top:"+(c.height-q-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");c.insertBefore(n,this.loader);e=this.editableRegion.textFields;b=c.width/e.length;d=a.getFieldFontSize(t);p=0;for(A=e.length;p<A;p++)"div"==e[p].type?(n.appendChild(e[p].container),e[p].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+
t+"px; position: absolute; left: "+p*b+"px; top: 0px;"),g=e[p].container.firstChild,g.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+d+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+t+"px; text-align: center; line-height: "+t+"px;"),f=g.offsetWidth,g.style.width=f+"px",g.firstChild.textContent=g.firstChild.textContent.substring(3,g.firstChild.textContent.length-3),e[p].container.lastChild.setAttribute("style",
"font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+d+"px; width:"+(b-f)+"px; height:"+t+"px; position:absolute; left:"+f+"px; top:0px; border:2px groove white;")):(n.appendChild(e[p]),e[p].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+d+"px; width:"+b+"px; height:"+t+"px; position:absolute; left:"+p*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=l;this.displaceRegionWest=s;c.width-=h;c.height=
c.height-q-t;p=0;for(A=this.spaces.length;p<A;p++)this.spaces[p].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,c=this.controls.length;b<c;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=
function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,c=this.spaces.length;b<c;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=
function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;if(a)return b[a]||(b[a]=
new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;if(a){if(!b[a]){var c=a.lastIndexOf("."),c=-1===c?a.lenght:c;a.substring(0,c);b[a]=new Audio(a);var d=function(){this.ready=1};b[a].addEventListener("canplaythrough",d);var e=function(){!this.canPlayType("audio/"+a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(b[a]=new Audio(a.replace("mp3",
"ogg")),b[a].addEventListener("canplaythrough",d),b[a].addEventListener("load",d),b[a].addEventListener("error",e),b[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};b[a].addEventListener("error",e);b[a].play();setTimeout(function(){b[a].pause()},15)}return b[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=
function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.id==a)return b;return{update:function(){},w:0}};var g;a.DescartesApp.prototype.getState=function(){var a,
b="",c=this.evaluator.variables,d;for(d in c)c.hasOwnProperty(d)&&(a=c[d],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=d&&"pi"!=d&&"e"!=d&&"Infinity"!=d&&"-Infinity"!=d&&"object"!=typeof a)&&(b=""!=b?b+"\n"+d+"="+a:d+"="+a));var c=this.evaluator.vectors,g;for(g in c)c.hasOwnProperty(g)&&(a=c[g],b=b+"\n"+g+"="+e(a));g=this.evaluator.matrices;for(var f in g)g.hasOwnProperty(f)&&(a=g[f],b=b+"\n"+f+"="+e(a));return b};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var b,c,d=
0,e=a.length;d<e;d++)b=a[d].split("="),2<=b.length&&(c=eval(b[1]),-1!=b[1].indexOf("[[")?(this.evaluator.matrices[b[0]]=c,this.evaluator.matrices[b[0]].rows=c.length,this.evaluator.matrices[b[0]].cols=c[0].length):-1!=b[1].indexOf("[")?(this.evaluator.vectors[b[0]]=c,this.evaluator.variables[b[0]+".long"]=c.length):this.evaluator.variables[b[0]]=c),this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,c="",d=0,e=this.controls.length;d<e;d++)"textfield"==this.controls[d].gui&&
this.controls[d].evaluate&&(a++,b+=this.controls[d].ok,this.controls[d].value=""==this.controls[d].value?"''":this.controls[d].value,c+=" \\n "+this.controls[d].id+"="+this.controls[d].value+"|"+this.controls[d].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+c};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,c=a.length;b<c;b++)"textfield"==a[b].gui&&a[b].evaluate&&a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=
function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function e(){a.getFeatures();if(a.hasCanvasSupport){for(var e=document.getElementsByTagName("*"),b=[],c=0,d=e.length;c<d;c++)"DescartesAppContainer"==e[c].className&&b.push(e[c]);c=0;for(d=b.length;c<d;c++)b[c].parentNode.removeChild(b[c]);for(var b=document.getElementsByTagName("applet"),c=document.getElementsByTagName("ajs"),e=
[],g=0,f=b.length;g<f;g++)d=b[g],(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"))&&e.push(d);g=0;for(f=c.length;g<f;g++)d=c[g],(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"))&&e.push(d);b=0;for(c=e.length;b<c;b++)a.apps.push(new a.DescartesApp(e[b])),e[b].className="DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,2)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}"}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};if(!window.hasOwnProperty("debugDescartesJS")||
!debugDescartesJS){var g=document.getElementById("StyleDescartesApps");g&&g.parentNode.removeChild(g);g=document.createElement("style");g.id="StyleDescartesApps";g.type="text/css";g.setAttribute("rel","stylesheet");g.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";document.head.appendChild(g)}a.onResize=function(){for(var e,b=0,c=a.apps.length;b<c;b++){e=a.apps[b].spaces;for(var d=0,g=e.length;d<g;d++)e[d].findOffset()}};a.receiveMessage=
function(e){if(0<a.apps.length&&(e=e.data))if("set"===e.type)a.apps[0].evaluator.setVariable(e.name,e.value);else if("update"===e.type)a.apps[0].update();else if("exec"===e.type){var b=a.apps[0].evaluator.getFunction(e.name),c=[];""!==e.value&&(c=e.value.toString().split(","));b&&b.apply(a.apps[0].evaluator,c)}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",e),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
