/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-05-31
*/
var babel=function(a){if(a.loadLib)return a;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto="#000000";a.maxenta=a.magenta="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise="#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert="#00ff00";
a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho="#ff0000";a.pink=a.rosa=a.arrosa=a.rose="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro="#404040";a.gris=a.gray=a.grisa=a.cinza="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=
"#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a.colour=a.color=a.kolorea=a.couleur=a.cor="color";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]=
"sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=
a.konfig=a["configura\u00e7\u00e3o"]="config";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=
a["preencher-"]="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=
a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=
a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=
"language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";
a.texto=a.text=a.testu=a.texte="text";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=
a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=
a["eixo-y"]="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";
a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto=
"auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=
a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=
a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=
a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=
a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=
a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=a.zentratu=a["centr\u00e9e"]=a.centrado="center";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=
a.filas_norte=a.linhas_norte=a.files_nord="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud="rowsSouth";a.ancho_este=a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=
a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]="initAnimation";a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=
a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=
a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=
a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=
a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=
a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]="activeif";a.rotfin=a.finrot=a.bukrot="endrot";a.posfin=a.finpos=a.bukpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=
a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";
a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte="onlyText";a.evaluar=a.evaluate="evaluate";a.respuesta=a.answer="answer";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text="border";
a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.malla=a.mesh="mesh";a.local=a.Local="local";a.loadLib=!0;return a}(babel||{}),descartesJS=function(a){function e(a,b,c){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);j(a,b,c.controls)}function j(a,b,c){for(var g,f=
c.length-1;0<=f;f--)g=c[f],a.drawImage(g.getScreenshot(),b.offsetLeft+g.x,b.offsetTop+g.y)}if(a.loadLib)return a;var k=2*Math.PI,b=360/k,d=k/360,c=Math.floor,h,f,q,m,l,p,n,s,g,t;a.rangeOK=1;a.extend=function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&(a.prototype[c]=b.prototype[c]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*b};a.degToRad=function(a){return a*d};a.convertFont=function(a){if(""==a)return a;
h=a.split(",");f="";"bold"==h[1].toLowerCase()?f+="Bold ":"italic"==h[1].toLowerCase()||"italics"==h[1].toLowerCase()?f+="Italic ":"bold+italic"==h[1].toLowerCase()&&(f+="Italic Bold ");f+=h[2]+"px ";q=h[0].split(" ")[0].toLowerCase();return f="serif"===q||"times new roman"===q||"timesroman"===q||"times"===q?f+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===q||"arial"===q||"helvetica"===q?f+"Arial, Helvetica, 'Droid Sans', Sans-serif":f+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};
a.drawLine=function(a,b,g,f,d,h,e){a.lineWidth=e||1;a.strokeStyle=h||"black";h=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(c(b)+h,c(g)+h);a.lineTo(c(f)+h,c(d)+h);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;m=a.evalExpression(b);l=c(255*m[0][0]);p=c(255*m[0][1]);n=c(255*m[0][2]);s=1-m[0][3];return"rgba("+l+","+p+","+n+","+s+")"};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 c,g,f,h,d,e,k,m;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(a){if(20>=a)return this.originalToFixed(a);a=0>a?0:parseInt(a);c=this.toString();
d=c.indexOf("e");g=c.indexOf(".");if(-1!==d)if(e=c.split("e"),k=e[0],m=parseInt(e[1]),0>g+m){var b=Math.abs(g+m);c="0."+Array(b+1).join("0")+k.replace(".","");g=1}else k=k.replace(".",""),c=k+Array(m-k.length+2).join("0"),g=-1;f="";if(-1===g)return 0<a&&(f="."),f+=Array(a+1).join("0"),c+f;h=c.length-g-1;if(h>=a)return 0<a?c.substring(0,g+1+a):c.substring(0,g);b=0;for(a-=h;b<a;b++)f+="0";return c+f}};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],g=a.pageX,t=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(g=a.pageX,t=a.pageY):(g=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,t=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:g,y:t}};a.getTextWidth=function(b,c){a.ctx.font=c;return a.ctx.measureText(b).width};var u=document.createElement("span");u.appendChild(document.createTextNode("\u00c1p"));var r=document.createElement("div");
r.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var w=document.createElement("div");w.setAttribute("style","margin: 0; padding: 0;");w.appendChild(u);w.appendChild(r);var z={};a.getFontMetrics=function(a){if(z[a])return z[a];u.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");document.body.appendChild(w);var b={};r.style.verticalAlign="baseline";b.ascent=r.offsetTop-u.offsetTop;r.style.verticalAlign="bottom";b.h=r.offsetTop-u.offsetTop;b.descent=b.h-b.ascent;b.baseline=
b.ascent;document.body.removeChild(w);return z[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],c,g=document.createElement("canvas"),f=new Image;if(b){g.setAttribute("width",b.width);g.setAttribute("height",b.height);for(var h=g.getContext("2d"),d=0,k=b.spaces.length;d<k;d++)c=b.spaces[d],"R2"===c.type&&(h.drawImage(c.backgroundCanvas,c.x,c.y),h.drawImage(c.canvas,c.x,c.y),j(h,c.container,
c.ctrs));0<b.northSpace.controls.length&&e(h,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&e(h,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&e(h,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&e(h,b.westSpace.container,b.westSpace);f.src=g.toDataURL("image/png")}return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j;a.openExternalFile=function(a){e=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(d){b=
!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(c){try{b=new ActiveXObject("Microsoft.XMLHTTP")}catch(h){b=!1}}j=b;j.open("GET",a,!1);try{j.send(null),e=j.responseText,e.match(String.fromCharCode(65533))&&(j.open("GET",a,!1),j.overrideMimeType("text/plain; charset=ISO-8859-1"),j.send(null),e=j.responseText)}catch(f){console.log("Error to load the file :",a),e=null}return e};return a}(descartesJS||{}),descartesJS=function(a){function e(a){d=a.trim();a={ignoreAcents:!1,
ignoreCaps:!1,regExp:null};d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,d.length-1),"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,d=d.substring(1,d.length-1)));"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,d=d.substring(1,d.length-1),d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,d.length-1)));"*"===d.charAt(0)&&"*"!==d.charAt(d.length-1)?d=d.substring(1)+"$":"*"!==d.charAt(0)&&"*"===d.charAt(d.length-1)?d="^"+d.substring(0,d.length-1):"*"!==
d.charAt(0)&&"*"!==d.charAt(d.length-1)?d="^"+d+"$":"*"===d.charAt(0)&&"*"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d=d.replace(/\?/g,"[\\S\\s]{1}");a.regExp=d;return a}function j(a,b){d=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=d.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,
a.expr[1].length-1))};return a}function k(a,b,c){b=parseFloat(b);q=a.expr[0];m=a.expr[1];l=c.evalExpression(q.expr);p=c.evalExpression(m.expr);n="("==q.type;s="["==q.type;g=")"==m.type;t="]"==m.type;return(n&&b>l||s&&b>=l)&&(g&&b<p||t&&b<=p)?1:0}function b(a){return a.toString().replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,
"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,"N")}if(a.loadLib)return a;var d,c,h,f,q,m,l,p,n,s,g,t;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 g=0,f=a.length;g<f;g++){c=a[g].split("&");h=[];for(var k=0,m=c.length;k<m;k++)d=c[k],-1!==d.indexOf(",")&&("("===d.charAt(0)||"["===d.charAt(0))&&(")"===d.charAt(d.length-1)||"]"===d.charAt(d.length-
1))?h.push(j(d,b)):h.push(e(d));a[g]=h}return a};a.escorrecto=function(g,h,d,e){d=d||a.externalEvaluator;e=e||a.buildRegularExpresionsPatterns(g,d);h=b(h);g=0;for(var m=e.length;g<m;g++){c=e[g];f=!0;for(var l=0,j=c.length;l<j;l++)f=c[l].regExp?f&&!!h.match(b(c[l].regExp),"i"):f&&k(c[l],h,d);if(f)return 1}return 0};a.esCorrecto=function(g,h,e,m){e=e||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(g,e);g=0;for(var l=m.length;g<l;g++){c=m[g];f=!0;for(var j=0,q=c.length;j<q;j++)(d=c[j].regExp)?
(c[j].ignoreAcents&&(h=b(h),d=b(d)),c[j].ignoreCaps&&(h=h.toLowerCase(),d=b(d).toLowerCase()),f=f&&!!h.match(d)):f=f=f&&k(c[j],h,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,j,k,b,d,c,h,f,q,m;a.Color=function(a,c){this.b=this.g=this.r=0;this.a=1;this.evaluator=c;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,h=b.length;f<h;f++)d=
parseInt(b[f],16),b[f]!=d.toString(16)&&b[f]!=="0"+d.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((d/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){c=
[];for(var b=q=f=h=0,d=a.length;b<d;b++)m=a.charAt(b),"("===m?h++:")"===m?h--:"["===m?f++:"]"===m?f--:","===m&&(0===h&&0===f)&&(c.push(a.substring(q,b)),q=b+1);c.push(a.substring(q));return c};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){j=this.evaluator;this.r=e(255*j.evalExpression(this.rExpr));this.g=e(255*j.evalExpression(this.gExpr));this.b=e(255*j.evalExpression(this.bExpr));this.a=1-j.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,j=document.createElement("meta");j.setAttribute("http-equiv","X-UA-Compatible");j.setAttribute("content","chrome=1");e.appendChild(j);j=document.createElement("meta");j.setAttribute("name","viewport");j.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
e.appendChild(j);j=document.createElement("meta");j.setAttribute("name","apple-mobile-web-app-capable");j.setAttribute("content","yes");e.appendChild(j);j=document.createElement("meta");j.setAttribute("name","apple-mobile-web-app-status-bar-style");j.setAttribute("content","black-translucent");e.appendChild(j);(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,j=Math.floor,k=Math.random,b=Math.round,d=Math.abs,c=String.fromCharCode,h,f,q,m,l,p,n,s,g,t;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){h=[];for(var b=0;256>b;b++)h[b]=c(this.alfanum(j(d(7.5*(e(1*b-a)+e(1.4*b+a)+e(0.6*b-a)+e(2.2*b+a))))));return h.join("")};a.Krypto.prototype.encode=function(a){f=j(31*k());this.key=this.getKey(f);m=c(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;p=Array(3*a.length);for(var c=0,f=a.length;c<f;c++)g=256*j(a[c]+128)+b(255*k())+65536*b(255*k()),t=j((g<<this.shift(c))/256),p[3*c]=this.alfanum(t%32),p[3*c+1]=this.alfanum(t/32%
32),p[3*c+2]=this.alfanum(t/1024%32);return p};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;n=Array(a.length/3);for(var b=0,c=n.length;b<c;b++)t=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),g=j(256*t>>this.shift(b)),s=j(g/256)%256-128,0>s&&(s+=256),n[b]=s;return n};a.Krypto.prototype.alfanum=function(a){a=j(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,c=a.length;b<c;b++)m[b]=a.charCodeAt(b);return m};a.Krypto.prototype.bytesToString=function(a){for(var b=0,g=a.length;b<g;b++)a[b]=c(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){q=this.key.charCodeAt(a%this.key.length);m=this.numalfa(q);l=j(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,j){this.parent=e;var k=e.evaluator,b=k.parser,d=new a.Auxiliary(e);this.delay=j.delay?b.parse(j.delay):b.parse("60");this.loop=j.loop?j.loop:!1;this.auto=void 0==j.auto&&2===this.parent.version?!0:j.auto;this.controls=j.controls;this.init=d.splitInstructions(b,j.init);this.doExpr=d.splitInstructions(b,j.doExpr);j.whileExpr&&(this.whileExpr=b.parse(j.whileExpr));var c=this,h,f,q=c.doExpr.length;
this.animationExec=function(){for(f=0;f<q;f++)k.evalExpression(c.doExpr[f]);c.parent.update();c.playing&&(0<k.evalExpression(c.whileExpr)||c.loop)?(h=k.evalExpression(c.delay),c.timer=setTimeout(c.animationExec,10>h?10:h)):(c.stop(),c.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,j=this.init.length;a<j;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,j){a.Action.call(this,e,j);this.parameter=
j};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,j){a.Action.call(this,e,j);var k=this.evaluator,b=k.parser;j=(j||"").replace(/&squot;/g,"'");j=j.replace(/;/g,"\\n");j=j.split("\\n")||[""];for(var d=[],c,h=0,f=j.length;h<f;h++)(c=b.parse(j[h],!0))&&d.push(c);f=d.length;this.execute=function(){for(h=0;h<f;h++)k.evalExpression(d[h])}};a.extend(a.Calculate,a.Action);
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,j){a.Action.call(this,e,j);this.parameter=j;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,j){a.Action.call(this,e,j);this.parameter=j;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=no,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no");this.window.onload=function(){var a=this.document,
d=a.getElementsByTagName("applet");d&&0<d.length&&(this.innerWidth=d[0].width,this.height=d[0].height,a.body.style.margin="0px",a.body.style.padding="0px",d[0].parentNode.style.margin="0px",d[0].parentNode.style.padding="0px")}})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.About=function(e,j){a.Action.call(this,e,j);j||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+
1)+j)};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,j){a.Action.call(this,e,j)};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,j){a.Action.call(this,e,j)};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,j){a.Action.call(this,e,j)};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,j){a.Action.call(this,e,j)};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,j){a.Action.call(this,e,j)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.PlayAudio=function(e,j){a.Action.call(this,e,j);this.filenameExpr=j?this.evaluator.parser.parse("'"+j.split(" ")[0].trim()+"'"):"";this.filename=this.evaluator.evalExpression(this.filenameExpr);this.theAudio=e.getAudio(this.filename)};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=
function(){var a=this.theAudio;a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,b){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var d in b)b.hasOwnProperty(d)&&(this[d]=b[d])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var e,j;a.Auxiliary.prototype.splitInstructions=function(a,b){j=[];b=b?
b.split(";"):[""];for(var d=0,c=b.length;d<c;d++)(e=a.parse(b[d],!0))&&j.push(e);return j};a.Auxiliary.prototype.getPrivateVariables=function(a,b){j=[];b=b?b.split(/;|,/):[""];for(var d=0,c=b.length;d<c;d++)(e=a.parse(b[d],!0))&&j.push(e);d=0;for(c=j.length;d<c;d++)j[d]="asign"===j[d].type?j[d].childs[0].value:"identifier"===j[d].type?j[d].value:"";return j};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,j){a.Auxiliary.call(this,e,j);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"),j=document.createElement("label");j.appendChild(document.createTextNode("___"+this.id+"=___"));var k=document.createElement("input");k.value=this.expresionString;k.disabled=!this.editable;a.appendChild(j);a.appendChild(k);var b=this,d=b.evaluator.parser;k.onkeydown=function(a){13==a.keyCode&&(b.expresion=d.parse(this.value),d.setVariable(b.id,b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(e,j){a.Auxiliary.call(this,e,j);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector=function(e,j){var k=e.evaluator,b=k.parser;this.size=b.parse("3");a.Auxiliary.call(this,
e,j);this.expresion=this.expresion.split(";");var d;if(this.file){var c=document.getElementById(this.file);c&&"descartes/vectorFile"==c.type?(d=c.text,"\n"==d[0]&&(d=d.substring(1))):d=a.openExternalFile(this.file);null!=d&&(d=d.split("\n"));null==d||1==d.length&&""==d[0]?(d=[],this.size=0):(this.expresion=[],this.size=null);for(var h,f=0,q=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,c=0,m=d.length;c<m;c++)d[c].match(/./)&&(this.expresion[f]=this.id+"["+f+"]="+d[c],f++,(h=d[c].match(q))&&
this.parent.getImage(h));null===this.size&&(this.size=b.parse(this.expresion.length+""))}c=0;for(m=this.expresion.length;c<m;c++)(d=b.parse(this.expresion[c],!0))&&"asign"!=d.type&&(d=b.parse(this.id+"["+c+"]="+this.expresion[c],!0)),this.expresion[c]=d;b=[];c=0;for(m=k.evalExpression(this.size);c<m;c++)b.push(0);k.vectors[this.id]=b;this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var a=this.evaluator;a.setVariable(this.id+".long",a.evalExpression(this.size));for(var j=
0,k=this.expresion.length;j<k;j++)a.evalExpression(this.expresion[j])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,j){var k=e.evaluator,b=k.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,e,j);this.expresion=this.splitInstructions(b,this.expresion);var b=k.evalExpression(this.rows),d=k.evalExpression(this.columns),c=[];c.type="matrix";for(var h,f=0;f<d;f++){h=[];for(var q=0,m=b;q<m;q++)h.push(0);c[f]=h}k.matrices[this.id]=
c;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,j=a.evalExpression(this.rows),k=a.evalExpression(this.columns);a.setVariable(this.id+".filas",j);a.setVariable(this.id+".columnas",k);var b=a.matrices[this.id];b.rows=j;b.cols=k;j=0;for(k=this.expresion.length;j<k;j++)a.evalExpression(this.expresion[j])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(e,j){a.Auxiliary.call(this,e,j);var k=this.evaluator,
b=k.parser,d=this.id.indexOf("(");this.name=this.id.substring(0,d);this.params=this.id.substring(d+1,this.id.length-1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(b);this.expresion=b.parse(this.expresion);var c=this;this.functionExec=function(){if(c.numberOfParams<=arguments.length){for(var b=[],f=0,d=c.privateVars.length;f<
d;f++)b.push(k.getVariable(c.privateVars[f])),k.setVariable(c.privateVars[f],0);for(var e=[],f=0,d=c.params.length;f<d;f++)e[f]=k.getVariable(c.params[f]),k.setVariable(c.params[f],arguments[f]);f=0;for(d=c.init.length;f<d;f++)k.evalExpression(c.init[f]);do{f=0;for(d=c.doExpr.length;f<d;f++)k.evalExpression(c.doExpr[f])}while(0<k.evalExpression(c.whileExpr));var j=k.evalExpression(c.expresion);a.rangeOK=k.evalExpression(c.domain);f=0;for(d=c.params.length;f<d;f++)k.setVariable(c.params[f],e[f]);f=
0;for(d=c.privateVars.length;f<d;f++)k.setVariable(c.privateVars[f],b[f]);return j}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,j){a.Auxiliary.call(this,e,j);var k=this.evaluator;this.parseExpressions(k.parser);this.algorithmExec=function(){for(var a=0,d=this.init.length;a<d;a++)k.evalExpression(this.init[a]);do{a=0;for(d=this.doExpr.length;a<d;a++)k.evalExpression(this.doExpr[a])}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,j){a.Auxiliary.call(this,e,j);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,j,k,b,d;a.Graphic=function(b,d){this.parent=b;this.evaluator=b.evaluator;var f=this.evaluator.parser;this.spaceID="E0";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="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=f.parse("2");for(var e in d)d.hasOwnProperty(e)&&(this[e]=d[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,f=0,d=a.length;f<d;f++)if(b=a[f],b.id==this.spaceID)return b;return a[0]};a.Graphic.prototype.getFamilyValues=function(){e=this.evaluator;j=e.evalExpression(this.family_interval);this.familyInf=j[0][0];this.familySup=j[0][1];this.fSteps=Math.round(e.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?
(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,f){e=this.evaluator;this.getFamilyValues();k=e.getVariable(this.family);if(0<=this.fSteps)for(var d=0,m=this.fSteps;d<=m;d++)e.setVariable(this.family,this.familyInf+d*this.family_sep),0<e.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,f));e.setVariable("_Text_H_",0);e.setVariable(this.family,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,h,f,k,m,j,p,n,s,g,t){if("rtfNode"===h.type)a.fillStyle=m.getColor(),a.strokeStyle=m.getColor(),a.textBaseline="alphabetic",h.draw(a,f,k,s,g,p,t);else{"simpleText"===h.type&&(h=h.toString(s,g).split("\\n"));f+=j.match("Arial")?
-2:j.match("Times")?-2:0;e=this.evaluator;a.fillStyle=m.getColor();a.font=j;a.textAlign=p;a.textBaseline=n;this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=parseInt(this.fontSize/12)+1.5);d=1.2*this.fontSize||0;m=0;for(j=h.length;m<j;m++)b=h[m],this.border&&(a.lineJoin="round",a.strokeText(b,f,k+d*m)),a.fillText(b,f,k+d*m)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,b){this.text=b.replace("&#x2013","\u2013");this.textElements=[];
this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var d="'",c=0,h=0,f=-1,e,m;c<b.length;)e=b.charAt(c),m=b.charAt(c-1),"["===e&&"\\"===m?(this.textElements.push(b.substring(h,c-1)+"["),this.textElementsMacros.push("'"+b.substring(h,c-1)+"['"),h=c+1):"]"===e&&"\\"===m?(this.textElements.push(b.substring(h,c-1)+"]"),this.textElementsMacros.push("'"+b.substring(h,c-1)+"]'"),h=c+1):"["===e&&-1==f?(this.textElements.push(b.substring(h,c)),this.textElementsMacros.push("'"+
b.substring(h,c)+"'"),h=c,f++):"["===e?f++:"]"===e&&0==f?(this.textElements.push(this.evaluator.parser.parse(b.substring(h,c+1))),this.textElementsMacros.push("["+b.substring(h,c+1)+"]"),h=c+1,f--):("]"==b.charAt(c)&&(f=0>f?f:f-1),d+=b.charAt(c)),c++;this.textElements.push(b.substring(h,c));this.textElementsMacros.push("'"+b.substring(h,c)+"'")};var e,j;a.SimpleText.prototype.toString=function(a,b){e="";for(var d=0,c=this.textElements.length;d<c;d++)"string"===typeof this.textElements[d]?e+=this.textElements[d]:
(j=this.evaluator.evalExpression(this.textElements[d])[0][0],""!==j&&("string"===typeof j?e+=j:(j=parseFloat(j),j=b?j.toFixed(a):parseFloat(j.toFixed(a)),e+=j.toString().replace(".",this.parent.decimal_symbol))));return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,j=2*Math.PI,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r,w,z,B,x,E,C,A,y,G,F,L,J,v,M,D,H,K,I,O,Q,P,R,N,T,S,U,V,Y,X,W;a.Equation=function(b,c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP=
"";a.Graphic.call(this,b,c);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();n=new a.R2;s=new a.R2;g=new a.R2;r=new a.R2;t=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"==this.expresion.type){var b=this.expresion.childs[0],c=this.expresion.childs[1];"identifier"==b.type&&"y"==b.value&&!c.contains("y")?(this.funExpr=c,this.drawAux=this.drawAuxFunY):
"identifier"==c.type&&"y"==c.value&&!b.contains("y")?(this.funExpr=b,this.drawAux=this.drawAuxFunY):"identifier"==b.type&&"x"==b.value&&!c.contains("x")?(this.funExpr=c,this.drawAux=this.drawAuxFunX):"identifier"==c.type&&("x"==c.value&&!b.contains("x"))&&(this.funExpr=c,this.drawAux=this.drawAuxFunX)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=function(){this.auxCanvas=document.createElement("canvas");var a=parseInt(this.evaluator.evalExpression(this.width));
this.width_2=parseInt(a/2)||1;this.auxCanvas.setAttribute("width",a);this.auxCanvas.setAttribute("height",a);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.beginPath();this.auxCtx.arc(this.width_2,this.width_2,this.width_2,0,2*Math.PI,!1);this.auxCtx.fill()};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,
this.color))};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(h,j,v){h.lineWidth=1;b=this.evaluator;d=b.parser;c=this.space;f=b.evalExpression(this.width);h.fillStyle=v.getColor();h.translate(-this.width_2,-this.width_2);d.getVariable("x");d.getVariable("y");q=c.w;m=c.h;l=e(q/8);3>l&&(l=3);p=e(m/8);3>p&&(p=3);k=[];n.set(0,0);s.set(0,0);g.set(0,0);for(F=e(p/2);F<m;F+=p)for(G=e(l/2);G<q;G+=l)if(this.abs_coord?(r.set(G,
F),u=this.newt.findZero(r),b.setVariable("x",u.x),b.setVariable("y",u.y),t.set(u.x,u.y)):(r.set(c.getRelativeX(G),c.getRelativeY(F)),u=this.newt.findZero(r),b.setVariable("x",u.x),b.setVariable("y",u.y),t.set(c.getAbsoluteX(u.x),c.getAbsoluteY(u.y))),w=e(t.ix()),z=e(t.iy()),!(0>w||w>=q||0>z||z>=m||k[w+z*c.w]))if(k[w+z*c.w]=!0,n.x=u.x,n.y=u.y,s.x=u.x,s.y=u.y,B=this.newt.getUnitNormal(),!(0==B.x&&0==B.y)){B.rotL90();g.x=B.x;g.y=B.y;E=x=0;for(C=!1;2>E;){C&&(g.x=-B.x,g.y=-B.y,u.x=n.x,u.y=n.y,s.x=u.x,
s.y=u.y,this.abs_coord?t.set(u.x,u.y):t.set(c.getAbsoluteX(u.x),c.getAbsoluteY(u.y)),w=t.ix(),z=t.iy(),C=!1,x=0);this.abs_coord?(u.x+=g.x,u.y+=g.y):(u.x+=g.x/c.scale,u.y+=g.y/c.scale);u=this.newt.findZero(u);b.setVariable("x",u.x);b.setVariable("y",u.y);g.x=u.x-s.x;g.y=u.y-s.y;g.normalize();if(0==g.x&&0==g.y)break;s.x=u.x;s.y=u.y;this.abs_coord?t.set(u.x,u.y):t.set(c.getAbsoluteX(u.x),c.getAbsoluteY(u.y));A=e(t.ix());y=e(t.iy());if(A!=w||y!=z)if(w=A,z=y,0<=w&&w<q&&0<=z&&z<m)if(x=0,k[w+z*c.w])break;
else k[w+z*c.w]=!0,a.rangeOK&&b.evalExpression(this.drawif)&&h.drawImage(this.auxCanvas,w,z);else C=!0,E++;else 4<++x&&(C=!0,E++)}}h.setTransform(1,0,0,1,0,0)};a.Equation.prototype.drawAuxFunY=function(g){b=this.evaluator;c=this.space;q=c.w;l=1/c.scale;J=c.getAbsoluteY(0);f=b.evalExpression(this.width);h=this.color.getColor();g.fillStyle=h;v=c.getRelativeX(0);b.setVariable("x",v);O=c.getAbsoluteX(v);Q=c.getAbsoluteY(b.evalExpression(this.funExpr));T=0;for(var d=1;d<q;d++){D=v+d*l;b.setVariable("x",
D);H=b.evalExpression(this.funExpr);b.setVariable("y",H);K=c.getAbsoluteX(D);I=c.getAbsoluteY(H);P=Math.min(T,H);R=Math.max(T,H);N={min:P,max:R};if(void 0!==H&&(a.rangeOK&&b.evalExpression(this.drawif))&&!this.hasSingularity(l,D,"x",D-l,T,D,H,N)){if(this.fillM||this.fillP)this.fillM&&(S=this.fillM.getColor()),this.fillP&&(U=this.fillP.getColor()),g.lineWidth=1,g.strokeStyle=I>J?S:U,g.beginPath(),g.moveTo(K+0.5,I),g.lineTo(K+0.5,J),g.stroke();g.lineWidth=f;g.strokeStyle=h;g.beginPath();g.moveTo(O,
Q);g.lineTo(K,I);g.stroke()}T=H||0;O=K;Q=I}};a.Equation.prototype.drawAuxFunX=function(g){b=this.evaluator;c=this.space;m=c.h;p=1/c.scale;L=c.getAbsoluteX(0);f=b.evalExpression(this.width);h=this.color.getColor();g.fillStyle=h;M=c.getRelativeY(m);b.setVariable("y",M);O=c.getAbsoluteX(b.evalExpression(this.funExpr));Q=c.getAbsoluteY(M);for(var d=0,e=1;e<m;e++){H=M+e*p;b.setVariable("y",H);D=b.evalExpression(this.funExpr);b.setVariable("x",D);K=c.getAbsoluteX(D);I=c.getAbsoluteY(H);P=Math.min(d,D);
R=Math.max(d,D);N={min:P,max:R};if(void 0!==H&&(a.rangeOK&&b.evalExpression(this.drawif))&&!this.hasSingularity(p,H,"y",H-p,d,H,D,N)){if(this.fillM||this.fillP)this.fillM&&(S=this.fillM.getColor()),this.fillP&&(U=this.fillP.getColor()),g.lineWidth=1,g.strokeStyle=K>L?S:U,g.beginPath(),g.moveTo(K,I+0.5),g.lineTo(L,I+0.5),g.stroke();g.lineWidth=f;g.strokeStyle=h;g.beginPath();g.moveTo(O,Q);g.lineTo(K,I);g.stroke()}d=D||0;O=K;Q=I}};a.Equation.prototype.hasSingularity=function(a,b,c,g,f,d,h,e){if(1E-12>
Math.abs(d-g)||1E-8>Math.abs(d-g)&&Math.abs(h-f)>Math.abs(a))return!0;V=!1;Y=b;X=(g+d)/2;this.evaluator.setVariable(c,X);W=this.evaluator.evalExpression(this.funExpr);e.min<=W&&W<=e.max?V=!1:(e.x=Math.min(e.min,W),e.y=Math.max(e.max,W),V=this.hasSingularity(a,b,c,g,f,X,W,e)||this.hasSingularity(a,b,c,X,W,d,h,e));this.evaluator.setVariable(c,Y);return V};a.drawPixel=function(a,b,c,g){a.moveTo(b,c);a.arc(b,c,g,0,j,!1)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");
a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Curve=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");this.width=b.evaluator.parser.parse("1");
this.fill="";a.Graphic.call(this,b,c);(this.visible=2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var j,k,b,d,c,h,f,q,m,l,p;a.Curve.prototype.update=function(){j=this.evaluator;k=j.evalExpression(this.parameter_interval);this.paraInf=k[0][0];this.paraSup=k[0][1];this.pSteps=j.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,s,g){j=this.evaluator;b=this.space;d=e(j.evalExpression(this.width));k.lineWidth=0<d?d:1E-6;k.lineCap="round";k.lineJoin="round";k.strokeStyle=g.getColor();c=j.getVariable(this.parameter);k.beginPath();j.setVariable(this.parameter,this.paraInf);h=j.evalExpression(this.expresion);this.exprX=this.abs_coord?e(h[0][0]):e(b.getAbsoluteX(h[0][0]));this.exprY=
this.abs_coord?e(h[0][1]):e(b.getAbsoluteY(h[0][1]));this.rotateExp&&(f=a.degToRad(j.evalExpression(this.rotateExp)),q=Math.cos(f),m=Math.sin(f),l=this.exprX*q-this.exprY*m,p=this.exprX*m+this.exprY*q,this.exprX=l,this.exprY=p);k.moveTo(this.exprX+0.5,this.exprY+0.5);for(g=1;g<=this.pSteps;g++)j.setVariable(this.parameter,this.paraInf+g*this.paraSep),h=j.evalExpression(this.expresion),this.exprX=this.abs_coord?e(h[0][0]):e(b.getAbsoluteX(h[0][0])),this.exprY=this.abs_coord?e(h[0][1]):e(b.getAbsoluteY(h[0][1])),
this.rotateExp&&(l=this.exprX*q-this.exprY*m,p=this.exprX*m+this.exprY*q,this.exprX=l,this.exprY=p),k.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(k.fillStyle=s.getColor(),k.fill());k.stroke();j.setVariable(this.parameter,c)};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;a.Sequence=function(e,k){this.size=e.evaluator.parser.parse("2");a.Graphic.call(this,e,k)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){var e=this.evaluator,k=e.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];if(this.rotateExp){var b=a.degToRad(e.evalExpression(this.rotateExp)),k=Math.cos(b),d=Math.sin(b),b=this.exprX*k-this.exprY*d,k=this.exprX*d+this.exprY*k;this.exprX=
b;this.exprY=k}e=e.evalExpression(this.range);this.rangeInf=e[0][0];this.rangeMax=e[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,k){var b=this.evaluator,d,c,h,f=Math.ceil(b.evalExpression(this.size)-0.4);a.fillStyle=k.getColor();a.beginPath();this.rangeInf>this.rangeMax&&(h=this.rangeInf,this.rangeInf=this.rangeMax,
this.rangeMax=h);for(var q=b.getVariable("n"),m=this.rangeInf,l=this.rangeMax;m<=l;m++)b.setVariable("n",m),h=b.evalExpression(this.expresion),this.exprX=h[0][0],this.exprY=h[0][1],this.abs_coord?d=h[0][1]:(d=this.space.getAbsoluteX(h[0][0]),c=this.space.getAbsoluteY(h[0][1])),a.moveTo(d,c),a.sequence(d,c,f,0,e,!0);b.setVariable("n",q);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,d+f,c-f,this.color,this.font,"start","alphabetic",b.evalExpression(this.decimals),this.fixed,!0)};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,j=Math.round;a.Point=function(b,c){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Point,a.Graphic);var k,b,d,c,h,f,q,m,l,p,n,s;a.Point.prototype.update=function(){k=this.evaluator;d=k.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(c=a.degToRad(k.evalExpression(this.rotateExp)),h=Math.cos(c),f=Math.sin(c),q=this.exprX*h-this.exprY*f,m=this.exprX*
f+this.exprY*h,this.exprX=q,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,c){k=this.evaluator;b=this.space;n=j(k.evalExpression(this.size));s=n+1;a.fillStyle=c.getColor();l=this.abs_coord?j(this.exprX):j(b.getAbsoluteX(this.exprX));p=this.abs_coord?j(this.exprY):j(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(l,p,n,
0,e,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,l+s+1,p-s,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,j=2*Math.PI,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r,w,z;a.Segment=function(b,c){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=
function(){k=this.evaluator;d=k.evalExpression(this.expresion);this.endPoints=[];for(var b=0,g=d.length;b<g;b++)this.endPoints[b]={x:d[b][0],y:d[b][1]};if(this.rotateExp){c=a.degToRad(k.evalExpression(this.rotateExp));h=Math.cos(c);f=Math.sin(c);b=0;for(g=this.endPoints.length;b<g;b++)q=this.endPoints[b].x*h-this.endPoints[b].y*f,m=this.endPoints[b].x*f+this.endPoints[b].y*h,this.endPoints[b].x=q,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,c,f){k=this.evaluator;b=this.space;l=e(k.evalExpression(this.width));a.lineWidth=0<l?l:1E-6;g=k.evalExpression(this.size);0>g&&(g=0);a.fillStyle=c.getColor();a.strokeStyle=f.getColor();a.lineCap="round";p=10+a.lineWidth;t=0==a.lineWidth%2?0:0.5;this.abs_coord?(u=e(this.endPoints[0].x),r=e(this.endPoints[0].y),w=e(this.endPoints[1].x),z=e(this.endPoints[1].y)):(u=e(b.getAbsoluteX(this.endPoints[0].x)),
r=e(b.getAbsoluteY(this.endPoints[0].y)),w=e(b.getAbsoluteX(this.endPoints[1].x)),z=e(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(u+t,r+t);a.lineTo(w+t,z+t);a.stroke();a.beginPath();a.arc(u,r,g,0,j,!0);a.arc(w,z,g,0,j,!0);a.fill();this.text!=[""]&&(n=parseInt((u+w)/2)-3,s=parseInt((r+z)/2)+3,this.uber.drawText.call(this,a,this.text,n+p,s-p,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,j=Math.round,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r,w,z;a.Arrow=function(b,c){this.width=b.evaluator.parser.parse("5");this.size=b.evaluator.parser.parse("2");this.spear=b.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,b,c)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){k=this.evaluator;b=k.evalExpression(this.expresion);this.endPoints=[];for(var g=0,e=b.length;g<e;g++)this.endPoints[g]={x:b[g][0],y:b[g][1]};if(this.rotateExp){d=a.degToRad(k.evalExpression(this.rotateExp));
c=Math.cos(d);h=Math.sin(d);g=0;for(e=this.endPoints.length;g<e;g++)f=this.endPoints[g].x*c-this.endPoints[g].y*h,q=this.endPoints[g].x*h+this.endPoints[g].y*c,this.endPoints[g].x=f,this.endPoints[g].y=q}};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(b,c,f){k=this.evaluator;m=this.space;k.evalExpression(this.size);n=k.evalExpression(this.width);
1>n&&(n=1);s=Math.ceil(n/2);g=m.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);t=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=f.getColor();b.lineWidth=2;this.abs_coord?(u=j(this.endPoints[0].x),r=j(this.endPoints[0].y),w=j(this.endPoints[1].x),z=j(this.endPoints[1].y)):(u=j(m.getAbsoluteX(this.endPoints[0].x)),r=j(m.getAbsoluteY(this.endPoints[0].y)),w=j(m.getAbsoluteX(this.endPoints[1].x)),
z=j(m.getAbsoluteY(this.endPoints[1].y)));c=k.evalExpression(this.spear);0>c&&(c=0);b.save();b.translate(u,r,t);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):(t*=g,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(-s,e(-s));b.lineTo(e(t-c-n),e(-s));b.lineTo(e(t-2*c),e(-c-s));b.lineTo(e(t),0);b.lineTo(e(t-2*c),e(c+s));b.lineTo(e(t-c-n),e(s));b.lineTo(-s,
e(s));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(l=parseInt((u+w)/2)-3,p=parseInt((r+z)/2)+3,this.uber.drawText.call(this,b,this.text,l,p,f,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,j,k,b,d,c,h,f,q,m,l,p,n;a.Polygon=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);
a.Polygon.prototype.update=function(){j=this.evaluator;b=j.evalExpression(this.expresion);for(var e=0,g=b.length;e<g;e++)this.endPoints[e]={x:b[e][0],y:b[e][1]};if(this.rotateExp){d=a.degToRad(j.evalExpression(this.rotateExp));c=Math.cos(d);h=Math.sin(d);e=0;for(g=this.endPoints.length;e<g;e++)f=this.endPoints[e].x*c-this.endPoints[e].y*h,q=this.endPoints[e].x*h+this.endPoints[e].y*c,this.endPoints[e].x=f,this.endPoints[e].y=q}};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,
this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Polygon.prototype.drawAux=function(a,b,c){j=this.evaluator;k=this.space;m=e(j.evalExpression(this.width));a.lineWidth=0<m?m:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";l=0<m?0.5:0;p=this.abs_coord?e(this.endPoints[0].x):e(k.getAbsoluteX(this.endPoints[0].x));n=this.abs_coord?e(this.endPoints[0].y):e(k.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(p+l,n+
l);c=1;for(var f=this.endPoints.length;c<f;c++)p=this.abs_coord?e(this.endPoints[c].x):e(k.getAbsoluteX(this.endPoints[c].x)),n=this.abs_coord?e(this.endPoints[c].y):e(k.getAbsoluteY(this.endPoints[c].y)),a.lineTo(p+l,n+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;a.Arc=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=
b.evaluator.parser.parse("1");this.init=b.evaluator.parser.parse("0");this.end=b.evaluator.parser.parse("90");a.Graphic.call(this,b,c)};a.extend(a.Arc,a.Graphic);var j,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r,w,z,B,x,E,C,A;a.Arc.prototype.update=function(){j=this.evaluator;k=j.evalExpression(this.center);this.exprX=k[0][0];this.exprY=k[0][1];this.rotateExp&&(b=a.degToRad(j.evalExpression(this.rotateExp)),d=Math.cos(b),c=Math.sin(b),h=this.exprX*d-this.exprY*c,f=this.exprX*c+this.exprY*d,this.exprX=h,this.exprY=
f);q=j.evalExpression(this.init);m=j.evalExpression(this.end);"(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type?(this.vectors=!0,l=q[0][0],p=q[0][1],n=m[0][0],s=m[0][1],g=Math.acos((1*l+0*p)/Math.sqrt(l*l+p*p)),t=Math.acos((1*n+0*s)/Math.sqrt(n*n+s*s)),0<l&&(0<p&&!this.abs_coord)&&(g=2*Math.PI-g),0<l&&(0>p&&this.abs_coord)&&(g=2*Math.PI-g),0>l&&(0>
p&&this.abs_coord)&&(g=2*Math.PI-g),0>l&&(0<p&&!this.abs_coord)&&(g=2*Math.PI-g),0<n&&(0<s&&!this.abs_coord)&&(t=2*Math.PI-t),0<n&&(0>s&&this.abs_coord)&&(t=2*Math.PI-t),0>n&&(0>s&&this.abs_coord)&&(t=2*Math.PI-t),0>n&&(0<s&&!this.abs_coord)&&(t=2*Math.PI-t),u=Math.min(g,t),r=Math.max(g,t),g=u,t=r,t-g>Math.PI&&this.abs_coord&&(g=r,t=u),t-g<=Math.PI&&!this.abs_coord&&(g=r,t=u),this.iniAng=g,this.endAng=t):(this.vectors=!1,this.iniAng=a.degToRad(q),this.endAng=a.degToRad(m))};a.Arc.prototype.draw=function(){this.uber.draw.call(this,
this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(a,b,c){j=this.evaluator;w=this.space;z=this.abs_coord?e(this.exprX):e(w.getAbsoluteX(this.exprX));B=this.abs_coord?e(this.exprY):e(w.getAbsoluteY(this.exprY));x=j.evalExpression(this.radius);!this.vectors&&this.iniAng>this.endAng&&(E=this.iniAng,this.iniAng=this.endAng,this.endAng=E);0>x&&(x=0);C=!1;this.abs_coord||(x*=w.scale,this.vectors||(this.iniAng=
-this.iniAng,this.endAng=-this.endAng,C=!0));this.vectors&&(C=this.abs_coord?!1:!0);A=e(j.evalExpression(this.width));a.lineWidth=0<A?A:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();a.beginPath();a.arc(z,B,x,this.iniAng,this.endAng,C);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,z+4,B-2,this.color,this.font,"start","alphabetic",j.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){function e(a,
b,c){f=4*(b+c*a.width);return{r:a.data[f],g:a.data[f+1],b:a.data[f+2],a:a.data[f+3]}}if(a.loadLib)return a;var j,k,b,d,c,h,f;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){j=this.evaluator.evalExpression(this.expresion);this.exprX=j[0][0];this.exprY=j[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,m){m.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)));d=[{x:k,y:b}];for(h=e(imageData,k,b);0<d.length;){c=d.pop();k=c.x;b=c.y;var j=e(imageData,k,b);if(h.r===j.r&&h.g===j.g&&h.b===j.b&&h.a===j.a){var j=imageData,p=m;f=4*(k+b*j.width);j.data[f+0]=p.r;j.data[f+1]=p.g;j.data[f+2]=p.b;j.data[f+3]=255-p.a;0<k&&d.push({x:k-1,y:b});k<imageData.width-
1&&d.push({x:k+1,y:b});d.push({x:k,y:b-1});d.push({x:k,y:b+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r;a.Text=function(b,c){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){e=
this.evaluator;j=e.evalExpression(this.expresion);this.exprX=j[0][0];this.exprY=j[0][1];this.rotateExp&&(k=a.degToRad(e.evalExpression(this.rotateExp)),b=Math.cos(k),d=Math.sin(k),c=this.exprX*b-this.exprY*d,h=this.exprX*d+this.exprY*b,this.exprX=c,this.exprY=h)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,b){r=this.evaluator.evalExpression(this.decimals);
"rtfNode"===this.text.type?(l=this.text,this.ascent=0):l=this.splitText(this.text.toString(r,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",r,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,c=a.length;b<c;b++)q=a[b],m=this.ctx.measureText(q).width,m>f?l=l.concat(this.splitWords(q,
f)):l.push(q);p=Math.floor(1.2*this.fontSize)*l.length;e.setVariable("_Text_H_",p);return l}e.setVariable("_Text_H_",0);e.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,b){n=a;s=[];g="";u=0;for(var c,f=0,d=a.length;f<d;f++)t=n.charAt(f)," "===t&&(lastIndexOfWhite=f),g+=t,Math.round(this.ctx.measureText(g).width)>b&&(c=a.substring(u,f+1)," "!==t&&(-1===c.indexOf(" ")?(lastIndexOfWhite=f,f--):f=lastIndexOfWhite),s.push(a.substring(u,lastIndexOfWhite)),g="",u=f+1);s.push(a.substring(u));
return s};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Image=function(b,c){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);var j,k,b,d,c,h,f,q,m,l,p,n,s,g;a.Image.prototype.update=function(){j=this.evaluator;k=j.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];this.rotateExp&&(b=a.degToRad(j.evalExpression(this.rotateExp)),
d=Math.cos(b),c=Math.sin(b),h=this.exprX*d-this.exprY*c,f=this.exprX*c+this.exprY*d,this.exprX=h,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((q=j.evalExpression(this.file))||""==q)this.img=this.parent.getImage(q)};a.Image.prototype.draw=
function(){this.uber.draw.call(this)};a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};a.Image.prototype.drawAux=function(b){j=this.evaluator;m=this.space;this.img&&(this.img.ready&&this.img.complete)&&(l=this.centered?0:this.img.width/2,p=this.centered?0:this.img.height/2,n=this.abs_coord?e(this.exprX):e(m.getAbsoluteX(this.exprX)),s=this.abs_coord?e(this.exprY):e(m.getAbsoluteY(this.exprY)),g=a.degToRad(-j.evalExpression(this.inirot)),b.translate(n+l,s+p),b.rotate(g),b.scale(this.scaleX,
this.scaleY),this.opacity&&(b.globalAlpha=j.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,c){f=4*(b+c*a.width);return{r:a.data[f],g:a.data[f+1],b:a.data[f+2],a:a.data[f+3]}}if(a.loadLib)return a;var j,k,b,d,c,h,f;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){j=this.evaluator.evalExpression(this.expresion);
this.exprX=j[0][0];this.exprY=j[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,m){m.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)));d=[{x:k,y:b}];for(h=e(imageData,k,b);0<d.length;){c=d.pop();k=c.x;
b=c.y;var j=e(imageData,k,b);if(h.r===j.r&&h.g===j.g&&h.b===j.b&&h.a===j.a){var j=imageData,p=m;f=4*(k+b*j.width);j.data[f+0]=p.r;j.data[f+1]=p.g;j.data[f+2]=p.b;j.data[f+3]=255-p.a;0<k&&d.push({x:k-1,y:b});k<imageData.width-1&&d.push({x:k+1,y:b});d.push({x:k,y:b-1});d.push({x:k,y:b+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;a.Macro=function(j,k){this.expresion=void 0;this.inirot=j.evaluator.parser.parse("0");a.Graphic.call(this,
j,k);for(var b in k)k.hasOwnProperty(b)&&(this[b]=k[b]);this.graphics=[];b=j.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 c=this.evaluator.evalExpression(this.expresion),h,f=2;c&&((h=document.getElementById(c))&&"descartes/macro"==h.type?(h=h.text,f=3):(h=a.openExternalFile(c))&&!h.match(/tipo_de_macro/g)&&(h=null));var q="|";if(h){h=h.replace(/&aacute;/g,
"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").split("\n").slice(f);for(var m,l,c=0,f=h.length;c<f;c++)h[c]&&(h[c]=b.split(h[c]),h[c]&&(h[c][0]&&
h[c][0][0]&&"id"===h[c][0][0])&&(m=h[c][0][1],l=m.indexOf("("),-1!=l&&(m=m.substring(0,l)),q+=m+"|"));for(var p,n,s,g,c=0,f=h.length;c<f;c++){p=h[c]||[];m=0;for(l=p.length;m<l;m++)if(n=e[p[m][0]],s=p[m][0].indexOf("."),-1!=s&&(n=e[p[m][0].substring(s+1)]),!("id"!=n&&void 0!=e[p[m][1]]))if("text"==n)if(p[m][1].match(/\{\\rtf1/)){n=p[m][1];var t=this;g=function(a,b){for(var c=d.tokenize(b.replace(/\&squot;/g,"'")),g=0,f=c.length;g<f;g++)if("identifier"==c[g].type&&q.match("\\|"+c[g].value+"\\|"))c[g].value=
t.name+"."+c[g].value;else if("identifier"==c[g].type&&-1!=(s=c[g].value.indexOf("."))&&q.match("\\|"+c[g].value.substring(0,s)+"\\|"))c[g].value=t.name+"."+c[g].value;return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+d.flatTokens(c)};n=n.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,g);n=n.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,g);p[m][1]=n}else{g=b.parseText(p[m][1]).textElementsMacros;for(var u=0,r=g.length;u<r;u++){n=d.tokenize(g[u].replace(/\&squot;/g,
"'"));for(var w=0,z=n.length;w<z;w++)"identifier"==n[w].type&&q.match("\\|"+n[w].value+"\\|")&&(n[w].value=this.name+"."+n[w].value);n=d.flatTokens(n).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");g[u]=n.substring(1,n.length-1)}p[m][1]=g.join("")}else{n=d.tokenize(p[m][1]);g=0;for(u=n.length;g<u;g++)if("identifier"==n[g].type&&q.match("\\|"+n[g].value+"\\|"))n[g].value=this.name+"."+n[g].value;else if("identifier"==n[g].type&&-1!=(s=n[g].value.indexOf("."))&&q.match("\\|"+n[g].value.substring(0,
s)+"\\|"))n[g].value=this.name+"."+n[g].value;p[m][1]=d.flatTokens(n)}}c=0;for(f=h.length;c<f;c++)if(h[c][0]){p="";n=!1;m=0;for(l=h[c].length;m<l;m++)"type"===e[h[c][m][0]]&&(p="espacio='"+this.spaceID+"' ",n=!0),p=p+h[c][m][0]+"='"+h[c][m][1]+"' ";h[c]=p;n?this.graphics.push(b.parseGraphic(h[c],this.abs_coord,this.background,this.inirot)):b.parseAuxiliar(h[c])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=
a[0][0];this.iniPosY=a[0][1]}};a.Macro.prototype.drawAux=function(a){for(var e=0,b=this.graphics.length;e<b;e++)this.inipos&&(this.graphics[e].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[e].draw(),a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sqrt,j=Math.sin,k=Math.cos,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r;a.norm3D=function(a){return e(a.x*
a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(c){b=a.norm3D(c);if(0===b)return{x:0,y:0,z:0};if(1===b)return{x:c.x,y:c.y,z:c.z};b=1/b;return{x:c.x*b,y:c.y*b,z:c.z*b}};a.dotProduct3D=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};a.crossProduct3D=function(a,b){return{x:a.y*b.z-a.z*b.y,y:a.z*b.x-a.x*b.z,z:a.x*b.y-a.y*b.x}};a.scalarProduct3D=function(a,b){return{x:a.x*b,y:a.y*b,z:a.z*b}};a.subtract3D=function(a,b){return{x:a.x-b.x,y:a.y-b.y,z:a.z-b.z}};a.add3D=function(a,b){return{x:a.x+b.x,y:a.y+b.y,z:a.z+
b.z}};a.equals3DEpsilon=function(a,b,c){return Math.abs(a.x-b.x)<=c&&Math.abs(a.y-b.y)<=c&&Math.abs(a.z-b.z)<=c};a.Vector4D=function(a,b,c,g){this.x=a||0;this.y=b||0;this.z=c||0;this.w=g||0};a.Matrix4x4=function(a,b,c,g,f,d,e,h,k,m,j,l,q,n,s,u){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=g||0;this.a10=f||0;this.a11=d||0;this.a12=e||0;this.a13=h||0;this.a20=k||0;this.a21=m||0;this.a22=j||0;this.a23=l||0;this.a30=q||0;this.a31=n||0;this.a32=s||0;this.a33=u||0};a.Matrix4x4.prototype.setIdentity=
function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,
this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(b){d=j(b);c=k(b);l=this.a10;p=this.a11;n=this.a12;s=this.a13;g=this.a20;t=this.a21;u=this.a22;r=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,l*c+g*
d,p*c+t*d,n*c+u*d,s*c+r*d,l*-d+g*c,p*-d+t*c,n*-d+u*c,s*-d+r*c,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){d=j(b);c=k(b);h=this.a00;f=this.a01;q=this.a02;m=this.a03;g=this.a20;t=this.a21;u=this.a22;r=this.a23;return new a.Matrix4x4(h*c+g*-d,f*c+t*-d,q*c+u*-d,m*c+r*-d,this.a10,this.a11,this.a12,this.a13,h*d+g*c,f*d+t*c,q*d+u*c,m*d+r*c,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){d=j(b);c=k(b);h=this.a00;f=this.a01;q=this.a02;m=this.a03;
l=this.a10;p=this.a11;n=this.a12;s=this.a13;return new a.Matrix4x4(h*c+l*d,f*c+p*d,q*c+n*d,m*c+s*d,h*-d+l*c,f*-d+p*c,q*-d+n*c,m*-d+s*c,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,c);a.fill();a.stroke()}function j(a,b){a.lineCap=h;a.lineJoin=f;this.frontColor.getColor();
this.backColor.getColor();a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var c=1,d=this.newV.length;c<d;c++)a.lineTo(this.newV[c].x,this.newV[c].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){this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor.getColor(),this.font,"left","alphabetic",this.decimals,this.fixed,!0)}function b(a){a.lineCap=h;a.lineJoin=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 d(b,c,f){q=a.subtract3D(b,c);m=a.subtract3D(b,f);return a.normalize3D(a.crossProduct3D(q,m))}if(a.loadLib)return a;var c=2*Math.PI,h="round",f="round",q,m,l,p,n;a.Primitive3D=function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);this.newV=[];"vertex"===this.type?this.draw=e:"face"===this.type?(this.normal=d(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=j):"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 c=0,f=this.vertices.length;c<f;c++)this.newV[c]=b.rotateVertex(this.vertices[c]),this.average.x+=this.newV[c].x,this.average.y+=this.newV[c].y,this.average.z+=this.newV[c].z;this.average=a.scalarProduct3D(this.average,1/f);2<this.vertices.length&&(this.normal=d(this.newV[0],
this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));c=this.depth=0;for(f=this.vertices.length;c<f;c++)this.newV[c]=b.project(this.newV[c]),this.depth+=this.newV[c].z;this.depth/=f};a.Primitive3D.prototype.drawText=function(b,c,f,d,e,h,k,m,j,q,C){if("rtfNode"==c.type)b.fillStyle=e,b.strokeStyle=e,b.textBaseline="alphabetic",c.draw(b,f,d,j,q,k,C);else{"simpleText"===c.type&&(c=c.toString(j,q).split("\\n"));f+=h.match("Arial")?-2:h.match("Times")?-2:0;l=this.evaluator;
b.fillStyle=a.getColor(l,e);b.font=h;b.textAlign=k;b.textBaseline=m;p=1.2*this.fontSize||0;e=0;for(h=c.length;e<h;e++)n=c[e],this.border&&b.strokeText(n,f,d+p*e),b.fillText(n,f,d+p*e)}};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var c=null,f=null,d=0,e=0,h=0,k=b.vertices.length;h<k;h++){var m=this.intersection(b.vertices[h],b.vertices[(h+1)%k]);if(null!==m)if(null===c){if(c=m,d=h,2===b.vertices.length){f=c;break}}else if(!a.equals3DEpsilon(m,c,1E-8)){f=m;e=h;break}}if(null!==
c&&null!==f){var h=this.isInterior(c)||this.isInterior(f),j=null,l=null;if(!h&&3<=b.vertices.length)for(var k=0,q=this.vertices.length;k<q;k++)if(m=b.intersection(this.vertices[k],this.vertices[(k+1)%q]),null!==m)if(null===j)j=m;else if(!a.equals3DEpsilon(m,j,1E-8)){l=m;break}if(h||null!==j&&null!==l&&b.isInterior(j)&&b.isInterior(l)){l=!0;q=b.vertices;j=m=null;if(2===q.length)a.equals(c,q[0],1E-8)||a.equals(c,q[1],1E-8)?l=!1:(m=[],m[0]=q[0],m[1]=c,j=[],j[0]=c,j[1]=q[1]);else for(var m=[],j=[],n=
0,h=k=0;h<q.length;h++)h<d?m[n++]=q[h]:h==d?(m[n++]=q[h],m[n++]=c,j[k++]=c):h<e?j[k++]=q[h]:h==e?(j[k++]=q[h],j[k++]=f,m[n++]=f):m[n++]=q[h];if(l)return c=[],c[0]=new a.Primitive3D({vertices:m,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),c[0].normal=b.normal,c[1]=new a.Primitive3D({vertices:j,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),c[1].normal=b.normal,c}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&
a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var c=a.dotProduct3D(b.vertices[0],b.normal),f=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(c-f))return!0;for(var d=1,h=this.vertices.length;d<h;d++){var e=a.dotProduct3D(this.vertices[d],b.normal);if(1E-8>Math.abs(c-e)||e>c&&f<c||e<c&&f>c)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,c){if(0<this.vertices.length){var f=a.subtract3D(c,b),d=a.dotProduct3D(f,this.normal);if(0!==d&&(d=a.dotProduct3D(a.subtract3D(this.vertices[0],
b),this.normal)/d,-1E-8<d&&1.00000001>d))return a.add3D(b,a.scalarProduct3D(f,d))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var c=0,f=a.subtract3D(this.vertices[0],b),d=0,h=this.vertices.length;d<h;d++){var e=a.subtract3D(this.vertices[(d+1)%h],b),k=a.dotProduct3D(a.crossProduct3D(f,e),this.normal);if(1E-8>Math.abs(k)){if(0>a.dotProduct3D(f,e))break}else{if(0>c&&0<k||0<c&&0>k)return!1;f=e;c=k}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e={x:0,y:0,z:0},j,k,b,d,c,h,f,q;a.Graphic3D=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");this.drawif=f.parse("1");this.abs_coord=!1;this.family="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;
this.text="";this.decimals=f.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=f.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=f.parse("(0,0,0)");this.model="color";for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=f.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);
this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10;this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=f.parse(this.inirot);this.endrot=f.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=
new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){j=this.evaluator;k=j.evalExpression(this.family_interval);this.familyInf=k[0][0];this.familySup=k[0][1];this.fSteps=Math.round(j.evalExpression(this.family_steps));this.family_sep=
0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){j=this.evaluator;this.getFamilyValues();b=j.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)j.setVariable(this.family,this.familyInf+a*this.family_sep),j.evalExpression(this.drawif)&&this.buildPrimitives();j.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(){c=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(c[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(c[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(c[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(c[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(c[0][1])),this.inirotM_Z=
this.inirotM_Z.setIdentity().rotateZ(a.degToRad(c[0][2])));c=this.evaluator.evalExpression(this.inipos);e={x:c[0][0],y:c[0][1],z:c[0][2]};this.iniposM=this.iniposM.setIdentity().translate(e);c=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(c[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(c[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(c[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(c[0][0])),
this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(c[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(c[0][2])));c=this.evaluator.evalExpression(this.endpos);e={x:c[0][0],y:c[0][1],z:c[0][2]};this.endposM=this.endposM.setIdentity().translate(e)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?d=this.inirotM.multiplyVector4(a):(d=this.inirotM_X.multiplyVector4(a),d=this.inirotM_Y.multiplyVector4(d),d=this.inirotM_Z.multiplyVector4(d));d=this.iniposM.multiplyVector4(d);
this.endrotEuler?d=this.endrotM.multiplyVector4(d):(d=this.endrotM_X.multiplyVector4(d),d=this.endrotM_Y.multiplyVector4(d),d=this.endrotM_Z.multiplyVector4(d));return d=this.endposM.multiplyVector4(d)};a.Graphic3D.prototype.parseExpression=function(){c=this.expresion.split("=");h=c[0];f=[];for(var a=1;a<c.length;a++)h+="=",q=c[a].lastIndexOf(" "),h+=-1!==q?c[a].substring(0,q):c[a],f.push(this.evaluator.parser.parse(h,!0)),h=c[a].substring(q+1);return f};var m;a.Graphic3D.prototype.splitFace=function(a){for(var b=
0,c=this.primitives.length;b<c;b++)if(m=[],"face"===this.primitives[b].type){for(var f=0,g=a.primitives.length;f<g;f++)"face"===a.primitives[f].type?m=m.concat(this.primitives[b].splitFace(a.primitives[f])):m.push(a.primitives[f]);a.primitives=m}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d;a.Point3D=function(b,d){a.Graphic3D.call(this,b,d)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();
j=e.evalExpression(this.expresion);k=j[0][0];b=j[0][1];d=j[0][2];this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(k,b,d,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:e.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(k,b,d,1))],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,
evaluator:e,text:this.text}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c;a.Segment3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=expr[0][0];j=expr[0][1];k=expr[0][2];b=expr[1][0];d=expr[1][1];c=expr[1][2];this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,
j,k,1)),this.transformVertex(new a.Vector4D(b,d,c,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h;a.Surface3D=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=
function(){e=this.evaluator;this.updateMVMatrix();k=e.getVariable("x");k=e.getVariable("y");k=e.getVariable("z");j=e.getVariable("u");k=e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);b=e.evalExpression(this.Nu);d=e.evalExpression(this.Nv);c=[];for(var f=0;f<=b;f++){e.setVariable("u",f/b);for(var q=0;q<=d;q++){e.setVariable("v",q/d);for(var m=0,l=this.expresion.length;m<l;m++)e.evalExpression(this.expresion[m]);c.push(this.transformVertex(new a.Vector4D(e.getVariable("x"),e.getVariable("y"),
e.getVariable("z"),1)))}}this.primitives=[];for(f=0;f<b;f++)for(q=0;q<d;q++)h=[],h.push(c[q+f*d+f]),h.push(c[q+1+f*d+f]),h.push(c[q+2+(f+1)*d+f]),h.push(c[q+1+(f+1)*d+f]),this.primitives.push(new a.Primitive3D({vertices:h,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}));e.setVariable("x",void 0);e.setVariable("y",void 0);e.setVariable("z",void 0);e.setVariable("u",j);e.setVariable("v",k)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e,j,k,b,d,c;a.Polygon3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);this.primitives=[];for(var h=0,f=expr.length-1;h<f;h++)e=expr[h][0],j=expr[h][1],k=expr[h][2],b=expr[h+1][0],d=expr[h+1][1],c=expr[h+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,
j,k,1)),this.transformVertex(new a.Vector4D(b,d,c,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c;a.Curve3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();b=evaluator.getVariable("x");
d=evaluator.getVariable("y");c=evaluator.getVariable("z");k=evaluator.getVariable("u");evaluator.setVariable("u",0);j=evaluator.evalExpression(this.Nu);e=[];for(var h=0;h<=j;h++){evaluator.setVariable("u",h/j);for(var f=0,q=this.expresion.length;f<q;f++)evaluator.evalExpression(this.expresion[f]);e.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}this.primitives=[];h=0;for(f=e.length-1;h<f;h++)this.primitives.push(new a.Primitive3D({vertices:[e[h],
e[h+1]],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}));evaluator.setVariable("x",b);evaluator.setVariable("y",c);evaluator.setVariable("z",d);evaluator.setVariable("u",k)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h,f,q;a.Triangle3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);
e=expr[0][0];j=expr[0][1];k=expr[0][2];b=expr[1][0];d=expr[1][1];c=expr[1][2];h=expr[2][0];f=expr[2][1];q=expr[2][2];this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,j,k,1)),this.transformVertex(new a.Vector4D(h,f,q,1)),this.transformVertex(new a.Vector4D(b,d,c,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 j=expr.length-1;0<=j;j--)e.push(this.transformVertex(new a.Vector4D(expr[j][0],expr[j][1],expr[j][2],1)));this.primitives=[];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,j,k,b,d;a.Polireg3D=function(b,d){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,d)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();e=evaluator.evalExpression(this.Nu);j=[this.transformVertex(new a.Vector4D(0,0,0,1))];k=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/
2;d=2*Math.PI/e;for(var c=0;c<e;c++)j.push(this.transformVertex(new a.Vector4D(k*Math.cos(d*c),b*Math.sin(d*c),0,1)));this.primitives=[];for(c=0;c<e;c++)this.primitives.push(new a.Primitive3D({vertices:[j[0],c+2<=e?j[c+2]:j[1],j[c+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,j,k,b;a.Text3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=
function(){e=this.evaluator;j=e.evalExpression(this.expresion);k=j[0][0];b=j[0][1];this.primitives=[];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}))};return a}(descartesJS||{}),descartesJS=function(a){function e(a,b,c,f,g){j.call(this,a/1.8,a/1.8,a/1.8,f,g)}function j(a,b,c,f,d){a/=2;b/=2;c/=2;this.changeGeometry(a,
b,c,f,d)||(this.vertices=[new g(a,c,b,1),new g(a,-c,b,1),new g(a,c,-b,1),new g(a,-c,-b,1),new g(-a,c,b,1),new g(-a,-c,b,1),new g(-a,c,-b,1),new g(-a,-c,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,c,f,d))}function k(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new g(0,0,a,1),new g(-0.49*a,-0.86*a,-0.32*a,1),new g(-0.49*a,0.86*a,-0.32*a,1),new g(1*a,0,-0.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,
b,c,f,d))}function b(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new g(0,0,a,1),new g(a,0,0,1),new g(-a,0,0,1),new g(0,a,0,1),new g(0,-a,0,1),new g(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,c,f,d))}function d(b,c,f,d,e){b/=3.4;if(!this.changeGeometry(b,c,f,d,e)){C=b/E;A=b*E;this.vertices=[new g(b,b,b,1),new g(b,b,-b,1),new g(b,-b,b,1),new g(b,-b,-b,1),new g(-b,b,b,1),new g(-b,b,-b,1),new g(-b,-b,b,1),new g(-b,
-b,-b,1),new g(0,C,A,1),new g(0,C,-A,1),new g(0,-C,A,1),new g(0,-C,-A,1),new g(C,A,0,1),new g(C,-A,0,1),new g(-C,A,0,1),new g(-C,-A,0,1),new g(A,0,C,1),new g(A,0,-C,1),new g(-A,0,C,1),new g(-A,0,-C,1)];y=(new a.Matrix4x4).setIdentity().rotateY(-n/6);for(var h=0,k=this.vertices.length;h<k;h++)this.vertices[h]=y.multiplyVector4(this.vertices[h]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,4,14,12,0],[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],
[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,c,f,d,e)}}function c(b,c,f,d,e){b/=4;if(!this.changeGeometry(b,c,f,d,e)){A=b*E;this.vertices=[new g(0,b,A,1),new g(0,b,-A,1),new g(0,-b,A,1),new g(0,-b,-A,1),new g(b,A,0,1),new g(b,-A,0,1),new g(-b,A,0,1),new g(-b,-A,0,1),new g(A,0,b,1),new g(A,0,-b,1),new g(-A,0,b,1),new g(-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]];y=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var h=0,k=this.vertices.length;h<k;h++)this.vertices[h]=y.multiplyVector4(this.vertices[h]);this.updateValues(b,c,f,d,e)}}function h(a,b,c,f,d){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[new g(0,0,b,1)];for(var e=1;e<f;e++){x=e*n/f;for(var h=0;h<d;h++)B=h*s/d,r=a*l(x)*p(B),w=c*l(x)*l(B),z=b*p(x),this.vertices.push(new g(r,w,z,1))}this.vertices.push(new g(0,0,-b,1));this.faces=[];
for(e=0;e<d;e++)this.faces.push([0,(e+1)%d+1,e%d+1]);for(e=1;e<f-1;e++)for(h=0;h<d;h++)this.faces.push([h+1+(e-1)*d,(h+1)%d+1+(e-1)*d,(h+1)%d+1+e*d,h+1+e*d]);for(e=0;e<d;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+e,this.vertices.length-1-d+(e+1)%d]);this.updateValues(a,b,c,f,d)}}function f(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var e=0;e<d;e++)for(var h=0;h<f;h++)r=a*(d-e)/d*p(h*s/f),w=c*(d-e)/d*l(h*s/f),z=b-2*e*b/d,this.vertices.push(new g(r,
w,z,1));this.vertices.push(new g(0,0,-b,1));this.faces=[];for(e=0;e<d-1;e++)for(h=0;h<f;h++)this.faces.push([h+e*f,(h+1)%f+e*f,(h+1)%f+(e+1)*f,h+(e+1)*f]);for(e=0;e<f;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+e,this.vertices.length-1-f+(e+1)%f]);this.updateValues(a,b,c,f,d)}}function q(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var e=0;e<d+1;e++)for(var h=0;h<f;h++)r=a*p(h*s/f),w=c*l(h*s/f),z=b-2*e*b/d,this.vertices.push(new g(r,w,
z,1));this.faces=[];for(e=0;e<d;e++)for(h=0;h<f;h++)this.faces.push([h+e*f,(h+1)%f+e*f,(h+1)%f+(e+1)*f,h+(e+1)*f]);this.updateValues(a,b,c,f,d)}}function m(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var c=0,f=this.fileData.length;c<f;c++)G=this.fileData[c],G.match(/^V\(/)?(F=G.substring(2,G.length-1).split(",").map(b),this.vertices.push(new g(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,p=Math.cos,n=Math.PI,s=2*n,g,t,u,r,w,z,B,x,E=1.6180339887,C,A,y,G,F;a.OtherGeometry=function(l,n){this.width=l.evaluator.parser.parse("2");this.height=l.evaluator.parser.parse("2");this.length=l.evaluator.parser.parse("2");g=a.Vector4D;a.Graphic3D.call(this,l,n);switch(this.type){case "cube":this.buildGeometry=e;break;case "box":this.buildGeometry=j;break;case "tetrahedron":this.buildGeometry=k;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=
!0;case "ellipsoid":this.buildGeometry=h;break;case "dodecahedron":this.buildGeometry=d;break;case "icosahedron":this.buildGeometry=c;break;case "cone":this.buildGeometry=f;break;case "cylinder":this.buildGeometry=q;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(){t=this.evaluator;this.updateMVMatrix();this.buildGeometry(t.evalExpression(this.width),
t.evalExpression(this.height),t.evalExpression(this.length),t.evalExpression(this.Nu),t.evalExpression(this.Nv));this.primitives=[];for(var b=0,c=this.faces.length;b<c;b++){u=[];for(var f=0,g=this.faces[b].length;f<g;f++)u.push(this.transformVertex(this.vertices[this.faces[b][f]]));this.primitives.push(new a.Primitive3D({vertices:u,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,c,f,g){return this.oldWidth===
a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===f&&this.oldNv===g};a.OtherGeometry.prototype.updateValues=function(a,b,c,f,g){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=g;this.oldNu=f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.max,j=Math.min,k=Math.PI,b=Math.cos,d=Math.sin,c=Math.abs,h,f,q,m,l,p,n,s,g,t,u,r,w,z,B,x,E,C;a.R2=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.set=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.copy=
function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return Math.round(e(j(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(e(j(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(){h=this.norm();0!=h&&this.div(h)};a.R2.prototype.rotR90=function(){h=this.x;this.x=this.y;this.y=-h};a.R2.prototype.rotL90=function(){h=this.x;this.x=-this.y;this.y=h};a.R2.prototype.rot=
function(a){q=this.copy();p=b(a);n=d(a);this.x=q.x*p-q.y*n;this.y=q.x*n+q.y*p};a.R2.prototype.rot=function(a){this.rot(a*k/180)};a.R2.prototype.intersection=function(b,f,d,h){s=f.x-b.x;g=d.x-h.x;t=d.x-b.x;u=f.y-b.y;r=d.y-h.y;w=d.y-b.y;C=s*r-g*u;return 1E-6<c(C)?(m=(t*r-w*g)/C,l=(-t*u+w*s)/C,0<=m&&1>=m&&0<=l&&1>=l?new a.R2(b.x+s*m,b.y+u*m):null):(f.x-d.x)*w!=(f.y-d.y)*t?null:b.x!=f.x?(z=j(b.x,f.x),B=e(b.x,f.x),z<=d.x&&d.x<=B?d:z<=h.x&&h.x<=B?h:null):d.x!=h.x?(x=j(d.x,h.x),E=e(d.x,h.x),x<=b.x&&b.x<=
E?b:x<=f.x&&f.x<=E?f:null):b.y!=f.y?(z=j(b.y,f.y),B=e(b.y,f.y),z<=d.y&&d.y<=B?d:z<=h.y&&h.y<=B?h:null):d.y!=h.y?(x=j(d.y,h.y),E=e(d.y,h.y),x<=b.y&&b.y<=E?b:x<=f.y&&f.y<=E?f:null):b.x==d.x&&b.y==d.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h,f;a.R2Newton=function(b,f){this.evaluator=b;this.constraint=f;if("=="==this.constraint.value||"<"==this.constraint.value||"<="==this.constraint.value||">"==this.constraint.value||">="==this.constraint.value)this.sign=
"<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0];c=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){e=this.evaluator;h=e.getVariable("x");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);j=e.evalExpression(this.constraint);c.x=(j-this.f0)/1E-12;c.x=!isNaN(c.x)?c.x:Infinity;e.setVariable("x",e.getVariable("x")-1E-12);e.setVariable("y",e.getVariable("y")+1E-12);j=e.evalExpression(this.constraint);c.y=(j-this.f0)/1E-12;c.y=!isNaN(c.y)?c.y:Infinity;e.setVariable("x",h);e.setVariable("y",f);return c};a.R2Newton.prototype.findZero=function(a){e=this.evaluator;d=a.copy();h=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 d;e.setVariable("x",h);e.setVariable("y",f);for(var c=0;256>c;c++)if(k=d.x,b=d.y,this.normal=this.gradient(d),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),d.x=k+this.normal.x,d.y=b+this.normal.y,1E-6>this.normal.norm()){0===this.normal.x&&0===this.normal.y&&(this.normal.x=d.x-a.x,this.normal.y=d.y-a.y);break}return d};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;a.Vector2D=function(a,j){this.x=a;this.y=j};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,j=Math.round,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r,w,z,B,x;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=this.parser=b.evaluator.parser;this.id="graphic"!==c.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==c.type?100:350;this.h="video"!==c.type?23:120;"graphic"!==c.type?"text"!==c.type?this.expresion=f.parse("(0,0,100,23)"):(this.expresion=f.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=f.parse("(0,0)");this.fixed=
2!=this.parent.version?!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt="graphic"!==c.type?new a.Color("f0f8ff"):new a.Color("ff0000");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:f.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=f.parse("1");this.activeif=f.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont=
"Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=f.parse("0");this.decimals=f.parse("2");this.min=f.parse("-Infinity");this.max=f.parse("Infinity");this.incr=f.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);if(("video"===this.type||"audio"===this.type)&&"interior"!==this.region)this.region="interior";void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==
this.name?"":this.name;f=this.evaluator.evalExpression(this.expresion);this.x=j(f[0][0]);this.y=j(f[0][1]);4==f[0].length&&(this.w=j(f[0][2]),this.h=j(f[0][3]));this.actionExec=b.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,b;if("interior"===this.region)for(var c=0,f=a.length;c<f;c++){if(b=a[c],b.id===this.spaceID)return b.addCtr(this),
this.zIndex=b.zIndex,b.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):this.parent.externalSpace.container;if("north"===this.region)return this.parent.northSpace.controls.push(this),
this.parent.northSpace.container;if("south"===this.region)return this.parent.southSpace.controls.push(this),this.parent.southSpace.container;if("east"===this.region)return this.parent.eastSpace.controls.push(this),this.parent.eastSpace.container;if("west"===this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;if("special"===this.region)return this.parent.specialSpace.controls.push(this),this.parent.specialSpace.container}a[0].addCtr(this);this.zIndex=a[0].zIndex;
return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a);b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){d=c=h=f=!1;q=this.evaluator.evalExpression(this.expresion);m=j(q[0][0]);d=j(this.x)!==m;this.x=m;m=j(q[0][1]);c=j(this.y)!==m;this.y=m;4===q[0].length&&(m=j(q[0][2]),h=j(this.w)!==m,this.w=m,m=j(q[0][3]),
f=j(this.h)!==m,this.h=m);if(h||f||d||c)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){g=this.parent;l=a+"";p=this.evaluator.evalExpression(this.decimals);n=l.indexOf(".");-1!=n&&(s=l.substring(n+1),s.length>p&&(l=parseFloat(l).toFixed(p)));if(this.fixed&&(2!==g.version||2===g.version&&!this.exponentialif))l=parseFloat(a).toFixed(p);this.exponentialif&&0!=parseFloat(l)&&(l=this.fixed&&2!==g.version?parseFloat(l).toExponential(p):parseFloat(l).toExponential(),l=l.toUpperCase(),
l=l.replace("+",""));return l=l.replace(".",g.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,c){this.linearGradient=this.ctx.createLinearGradient(0,0,0,c);k=c*c;for(var f=0;f<c;f++)b=e(f-35*c/100),this.linearGradient.addColorStop(f/c,"rgba(0,0,0,"+192*b*b/k/255+")")};a.Control.prototype.getScreenshot=
function(){r=this;t=document.createElement("canvas");t.setAttribute("width",r.w);t.setAttribute("height",r.h);u=t.getContext("2d");u.font=r.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";r.canvas&&(w=r.canvas.offsetLeft,z=r.canvas.offsetTop,u.drawImage(r.canvas,w,z));r.label&&(w=r.label.offsetLeft,z=r.label.offsetTop,B=r.label.offsetWidth,x=r.label.offsetHeight,u.fillStyle="#e0e4e8",u.fillRect(w,z,B,x),u.fillStyle="black",u.textAlign="center",u.textBaseline="middle",u.fillText(r.name,
w+B/2,z+x/2));r.field&&(w=r.field.offsetLeft,z=r.field.offsetTop,B=r.field.offsetWidth,x=r.field.offsetHeight,u.fillStyle="white",u.strokeStyle="#666666",u.lineWidth=1,u.fillRect(w,0,B,x),u.strokeRect(w+0.5,0.5,B-1,x-1),u.fillStyle="black",u.textAlign="center",u.textAlign="left",u.fillText(r.field.value,w+2,x/2));r.select&&(w=r.select.offsetLeft,z=r.select.offsetTop,B=r.select.offsetWidth,x=r.select.offsetHeight,u.fillStyle="#e0e4e8",u.strokeStyle="#666666",u.lineWidth=1,u.fillRect(w,0,B,x),u.strokeRect(w+
0.5,0.5,B,x-1),u.fillStyle="black",u.textAlign="center",u.textAlign="left",u.fillText(r.select.value,w+2,x/2),u.fillStyle="#c0c0c0",u.fillRect(w+B-15+0.5,0.5,15,x-1),u.strokeRect(w+B-15+0.5,0.5,15,x-1),u.fillStyle="black",u.beginPath(),u.moveTo(w+B-15+4.5,x/2-2.5),u.lineTo(w+B-15+8,x/2+2.5),u.lineTo(w+B-15+11.5,x/2-2.5),u.closePath(),u.fill());return t};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,j,k,b,d,c,h,f,q,m,l,p,n,s=900;a.Button=function(b,c){this.imageSrc=
"";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,c);-1===this.font_size&&(this.fontSizeNotSet=!0);this.name="["===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 f;this.imageSrc.match("_COLORES_")&&(f=this.imageSrc.split("_"),this.colorInt=new a.Color(f[2]),this.color=new a.Color(f[3]),this.font_size=this.parser.parse(f[5]),this.imageSrc=
"");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");f=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=f){var d=f.substr(0,f.lastIndexOf(".")),h=f.substr(f.lastIndexOf("."));f.toLowerCase().match(/vacio.gif$/)?(this.image.ready=1,3===this.parent.version&&(this.name=this.parser.parse("")),this.emptyImage={ready:!0},this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(f),this.imageOver=this.parent.getImage(d+"_over"+h),this.imageDown=this.parent.getImage(d+"_down"+h))}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(){j=this.evaluator;k=this.canvas;d=j.evalExpression(this.expresion);this.x=d[0][0];this.y=d[0][1];4==d[0].length&&(this.w=parseInt(d[0][2]),this.h=parseInt(d[0][3]));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=j.parser.parse(a.getFieldFontSize(this.h)+
""));this.createGradient(this.w,this.h);k.style.display=0<j.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){j=this.evaluator;k=this.canvas;this.activeIfValue=0<j.evalExpression(this.activeif);(this.drawIfValue=0<j.evalExpression(this.drawif))?(k.style.display="block",this.draw()):(this.click=!1,k.style.display="none");this.updatePositionAndSize()};a.Button.prototype.draw=function(){j=this.evaluator;b=this.ctx;c=j.evalExpression(this.font_size);h=j.evalExpression(this.name);
f=j.evalExpression(this.imageSrc);q="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);q&&q.ready?q!==this.emptyImage&&q.complete&&b.drawImage(q,parseInt((this.w-q.width)/2)+m,parseInt((this.h-q.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.imageOver.src&&(this.imageOver.ready&&this.over)&&b.drawImage(this.imageOver,parseInt((this.w-q.width)/2)+m,parseInt((this.h-q.height)/2)+l);""!=this.imageDown.src&&this.imageDown.ready&&this.click?b.drawImage(this.imageDown,parseInt((this.w-q.width)/2)+m,parseInt((this.h-q.height)/2)+l):this.click&&(a.drawLine(b,0,0,0,this.h-2,"gray"),a.drawLine(b,0,0,this.w-1,0,"gray"),b.fillStyle="rgba(0, 0, 0,"+24/255+")",b.fillRect(0,
0,this.w,this.h));b.fillStyle=this.color.getColor();b.font=this.italics+" "+this.bold+" "+c+"px Arial";b.textAlign="center";b.textBaseline="middle";this.colorInt.getColor()!=this.color.getColor()&&(b.lineJoin="round",b.lineWidth=parseInt(c/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(h,e(this.w/2+m)+0.5,e(this.h/2+l)+0.5));b.fillText(h,e(this.w/2+m)+0.5,e(this.h/2+l)+0.5);this.underlined&&(p=b.measureText(h).width,b.strokeStyle=this.color.getColor(),b.lineWidth=e(c/10)||2,b.lineCap="round",
b.beginPath(),b.moveTo(parseInt((this.w-p)/2)+m,e((this.h+c)/2)+e(c/5)-1.5+l),b.lineTo(parseInt((this.w+p)/2)+m,e((this.h+c)/2)+e(c/5)-1.5+l),b.stroke());this.activeIfValue||(b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h))};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(k);e.click&&(c.call(e),a=f?a:30,k=setTimeout(function(){b(a,c)},a))}function c(d){d.preventDefault();
document.activeElement.blur();e.whichButton=a.whichButton(d);"L"==e.whichButton&&e.activeIfValue&&(e.click=!0,e.draw(),e.evaluator.setVariable(e.id,e.evaluator.evalExpression(e.valueExpr)),"calculate"==e.action&&b(s,e.bottonPressed,!0),n?window.addEventListener("touchend",f):window.addEventListener("mouseup",f))}function f(a){if(e.activeIfValue||e.click)e.click=!1,e.draw(),"calculate"!=e.action&&e.bottonPressed(),a.preventDefault(),n?window.removeEventListener("touchend",f,!1):window.removeEventListener("mouseup",
f,!1)}function d(){e.over=!0;e.draw()}function h(){e.over=!1;e.click=!1;e.draw()}n=a.hasTouchSupport;var e=this,k;e.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;n?this.canvas.addEventListener("touchstart",c):(this.canvas.addEventListener("mousedown",c),this.canvas.addEventListener("mouseover",d),this.canvas.addEventListener("mouseout",h))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,
j,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);""!=this.name.trim()&&this.containerControl.appendChild(this.label);
this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var f=this.evaluator.evalExpression(this.incr);0<f?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(f).toString()):this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();
this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){e=this.evaluator;this.value=this.validateValue(e.evalExpression(this.valueExpr));var b=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var c=2!==this.parent.version?"":"_____",f=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),d=2+parseInt(this.h/2),g=parseInt(this.w/2-d/2),c=a.getTextWidth(this.name+c,this.fieldFontSize+"px Arial");this.visible||(g=this.w-
d,f=0);g<c&&(g=c);""==this.name&&(g=0);this.w-g-d<f&&(g=this.w-d-f);0>g&&(g=0);c=this.w-(g+d);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.canvas.setAttribute("width",d+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+g+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");
this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+d+"px; height : "+this.h/2+"px; left: "+g+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+d+"px; height : "+this.h/2+"px; left: "+g+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");
this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+(c-2)+"px; height : "+(this.h-2)+"px; left: "+(d+g)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+g+"px; height: "+this.h+"px; line-height: "+this.h+"px;");e.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=
function(){e=this.evaluator;0>=e.evalExpression(this.decimals)?(j=e.evalExpression(this.incr),0<j?this.originalIncr=this.incr=e.parser.parse(parseInt(j).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(){d=this.ctx;c=this.canvas.width;h=this.canvas.height;d.fillStyle="#f0f8ff";d.fillRect(0,0,c,h);d.fillStyle=this.linearGradient;d.fillRect(0,0,c,h);this.up?(f="gray",q="#f0f8ff"):
(f="#f0f8ff",q="gray");a.drawLine(d,0,0,c,0,f);a.drawLine(d,0,0,0,h/2,f);a.drawLine(d,0,h/2,c,h/2,q);this.down?(f="gray",q="#f0f8ff"):(f="#f0f8ff",q="gray");a.drawLine(d,0,h/2+1,c,h/2+1,f);a.drawLine(d,0,h/2+1,0,h,f);a.drawLine(d,0,h-1,c,h-1,q);m=[parseInt(c/2+1),parseInt(c/5+1),parseInt(c-c/5+1)];l=[parseInt(h/8+1),parseInt(h/8+1+h/4),parseInt(h/8+1+h/4)];d.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";d.beginPath();d.moveTo(m[0],l[0]);d.lineTo(m[1],l[1]);d.lineTo(m[2],l[2]);d.fill();l=[parseInt(h-
h/8),parseInt(h-h/8-h/4),parseInt(h-h/8-h/4)];d.fillStyle=this.activeIfValue?"#d00018":"#aa8888";d.beginPath();d.moveTo(m[0],l[0]);d.lineTo(m[1],l[1]);d.lineTo(m[2],l[2]);d.fill();d.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&d.fillRect(0,0,c,h/2);this.down&&d.fillRect(0,h/2,c,h)};a.Spinner.prototype.validateValue=function(a){e=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();p=parseFloat(e.evalExpression(e.parser.parse(a.replace(this.parent.decimal_symbol,
"."))));isNaN(p)&&(p=0);g=e.evalExpression(this.min);t=e.evalExpression(this.max);""===g&&(g=-Infinity);""===t&&(t=Infinity);p<g&&(p=g);p>t&&(p=t);this.discrete&&(n=e.evalExpression(this.incr),p=0==n?0:n*Math.round(p/n));s=e.evalExpression(this.decimals);0>=s&&(s=0);return p=parseFloat(parseFloat(p).toFixed(s))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-
this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(j);if(k.up||k.down)c.call(k),a=f?a:30,j=setTimeout(function(){b(a,c)},a)}function c(f){f.preventDefault();k.whichButton=a.whichButton(f);"L"==
k.whichButton&&k.activeIfValue&&(k.up=!0,b(m,k.increase,!0),k.draw())}function f(c){c.preventDefault();k.whichButton=a.whichButton(c);"L"==k.whichButton&&k.activeIfValue&&(k.down=!0,b(m,k.decrease,!0),k.draw())}function d(a){k.up=!1;clearInterval(j);k.draw();a.preventDefault()}function g(a){k.down=!1;clearInterval(j);k.draw();a.preventDefault()}function e(a){k.up=!1;clearInterval(j);k.draw();a.preventDefault()}function h(a){k.down=!1;clearInterval(j);k.draw();a.preventDefault()}u=a.hasTouchSupport;
var k=this,m=u?500:200,j;k.divUp.oncontextmenu=k.divDown.oncontextmenu=k.field.oncontextmenu=k.label.oncontextmenu=function(){return!1};u?this.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):this.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("keydown",function(a){13==a.keyCode&&k.changeValue(k.field.value)});u?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);u?this.divDown.addEventListener("touchstart",
f):this.divDown.addEventListener("mousedown",f);u||this.divUp.addEventListener("mouseout",d);u||this.divDown.addEventListener("mouseout",g);u?(this.divUp.addEventListener("touchend",e),window.addEventListener("touchend",e)):(this.divUp.addEventListener("mouseup",e),window.addEventListener("mouseup",e));u?(this.divDown.addEventListener("touchend",h),window.addEventListener("touchend",h)):(this.divDown.addEventListener("mouseup",h),window.addEventListener("mouseup",h))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h;a.TextField=function(b,c){a.Control.call(this,b,c);void 0===this.valueExprString&&(this.valueExprString="");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var d=this.answerPattern.indexOf("|");this.firstAnswer=
-1==d?this.answerPattern:this.answerPattern.substring(0,d)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));if(this.onlyText){if(!this.valueExprString.match(/^'/)||!this.valueExprString.match(/^'/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){return"''"==a||"'"==a?"":a};this.formatOutputValue=function(a){return a.toString()}}""==this.name.trim()&&(this.name="");this.containerControl=
document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){e=this.evaluator;this.value=this.validateValue(e.evalExpression(this.valueExpr));
var b=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var c=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),d=parseInt(this.w/2),h=a.getTextWidth(this.name,this.fieldFontSize+"px Arial");d<h&&(d=h);""==this.name&&(d=0);this.w-d<c&&(d=this.w-c);0>d&&(d=0);c=this.w-d;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+
this.zIndex+";");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(c-2)+"px; height : "+(this.h-2)+"px; left: "+d+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+
d+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":
"none";this.updatePositionAndSize();j=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!=j&&(this.value=this.validateValue(j),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";e=this.evaluator;b=parseFloat(e.evalExpression(e.parser.parse(a.toString().replace(this.parent.decimal_symbol,
"."))));isNaN(b)&&(b=0);d=e.evalExpression(this.min);""==d&&(d=-Math.Infinity);c=e.evalExpression(this.max);""==c&&(c=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(){h=a.hasTouchSupport;var b=this;b.label.oncontextmenu=function(){return!1};h?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(){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,j,k,b,d;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);var d=this.parser;this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var e,k=0,j=this.options.length;k<j;k++)e=this.options[k].split(/[\[\]]/,2),1==e.length?(this.menuOptions.push(e[0]),this.strValue.push(k.toString())):2==e.length&&(this.menuOptions.push(e[0]),""==e[1]?this.strValue.push(k.toString()):this.strValue.push(e[1]));k=0;for(j=this.strValue.length;k<j;k++)this.strValue[k]=d.parse(this.strValue[k]);
this.containerControl=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.select=document.createElement("select");k=0;for(j=this.menuOptions.length;k<j;k++)d=document.createElement("option"),d.innerHTML=this.menuOptions[k],this.select.appendChild(d);this.field=document.createElement("input");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&
this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Menu,a.Control);var c;a.Menu.prototype.init=function(){c=this.evaluator;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var b=0,f=0,d=0;this.value=c.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var e=0,k=this.menuOptions.length;e<k;e++)d=a.getTextWidth(this.menuOptions[e],this.fieldFontSize+
"px Arial"),d>b&&(b=d,f=e);b+=25;d=a.getTextWidth(this.formatOutputValue(c.evalExpression(this.strValue[f])),this.fieldFontSize+"px Arial")+7;f=a.getTextWidth(this.name,this.fieldFontSize+"px Arial")+10;""==this.name&&(f=0);this.visible||(d=0);for(e=this.w-d-f;e<b&&0<f;)f--,e++;for(;e<b&&0<d;)d--,e++;for(;f+e+d+1<this.w;)e++,d++;var b=f,k=b+e,d=this.w-k,j=this.formatOutputValue(c.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: "+f+"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 : "+(d-2)+"px; height : "+(this.h-2)+"px; left: "+k+"px;");this.select.setAttribute("id",this.id+"menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align: left; font-size: "+this.fieldFontSize+"px; width : "+e+"px; height : "+this.h+"px; left: "+b+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.selectedIndex=
this.indexValue;c.setVariable(this.id,parseFloat(j));this.update()};a.Menu.prototype.update=function(){c=this.evaluator;this.activeIfValue=0<c.evalExpression(this.activeif);this.drawIfValue=0<c.evalExpression(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();this.value=c.getVariable(this.id);this.field.value=
this.formatOutputValue(this.value);c.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));j=-1;k=Infinity;for(var c=0,d=this.strValue.length;c<d;c++)b=e(a-parseFloat(this.evaluator.evalExpression(this.strValue[c]))),b<=k&&(k=b,j=c);return j};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),
this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){d=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};d?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){b.value=b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);
b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,j="h",k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r,w,z,B,x,E;a.Scrollbar=
function(b,c){a.Control.call(this,b,c);this.orientation=this.w>=this.h?j:"v";this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.canvas);
this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){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));d=this.formatOutputValue(this.value);c=this.evaluator.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&(this.w=c[0][2],this.h=c[0][3]);this.orientation=this.w>=this.h?j:"v";this.initScroll(d);this.changeScrollPositionFromValue();this.prePos=this.pos;k.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(c){b=this;k=b.evaluator;var f="v"===b.orientation?
parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize="v"===b.orientation?f-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(f):10;var d=a.getTextWidth(c+"_",b.fieldFontSize+"px Arial"),g=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==b.name?0:f;b.fieldHeight=""==b.visible?0:f;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=b.h-b.labelHeight-b.fieldHeight,18<=b.canvasHeight+b.y-g&&(b.canvasHeight=g),d=0,d=b.fieldHeight,f=d+b.canvasHeight,b.canvasX=0,b.canvasY=b.fieldHeight,b.labelWidth=
b.w,b.labelY=f,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=f-b.downH,b.fieldWidth=b.w,b.fieldX=0,b.scrollManipulatorW=b.w,b.scrollManipulatorH=parseInt((b.canvasHeight-b.upHeight-b.downH-b.labelHeight-b.fieldHeight)/10),b.scrollManipulatorH=15>b.scrollManipulatorH?15:b.scrollManipulatorH,b.scrollManipulatorLimInf=f-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=d+b.downH;else{f=a.getTextWidth(b.name,b.fieldFontSize+"px Arial")+10;b.labelWidth=
f;b.fieldWidth=d;""==b.name&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(f=b.w-b.fieldWidth-b.labelWidth;58>f&&0<b.labelWidth;)b.labelWidth--,f++;for(;58>f&&0<b.fieldWidth;)b.fieldWidth--,f++;d=b.labelWidth;g=d+f;b.fieldWidth=b.w-g;b.canvasWidth=f;b.canvasHeight=b.h;b.canvasX=b.labelWidth;b.canvasY=0;b.fieldX=b.canvasWidth+b.labelWidth;b.labelHeight=b.h;b.labelY=0;b.upWidth=b.downW=15;b.upHeight=b.downH=b.h;b.upX=g-b.downW;b.upY=0;b.downX=b.labelWidth;b.downY=0;b.scrollManipulatorW=parseInt((b.canvasWidth-
b.upWidth-b.downW)/10);b.scrollManipulatorW=15>b.scrollManipulatorW?15:b.scrollManipulatorW;b.scrollManipulatorH=b.h;b.scrollManipulatorLimInf=d+b.downW;b.scrollManipulatorLimSup=d+b.canvasWidth-b.downW-b.scrollManipulatorW}b.containerControl.setAttribute("class","DescartesScrollbarContainer");b.containerControl.setAttribute("style","width: "+b.w+"px; height: "+b.h+"px; left: "+b.x+"px; top: "+b.y+"px; z-index: "+b.zIndex+";");b.canvas.setAttribute("width",b.w+"px");b.canvas.setAttribute("height",
b.h+"px");b.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");b.ctx=b.canvas.getContext("2d");b.divUp.setAttribute("class","DescartesCatcher");b.divUp.setAttribute("style","width : "+b.upWidth+"px; height : "+b.upHeight+"px; left: "+b.upX+"px; top: "+b.upY+"px;");b.divDown.setAttribute("class","DescartesCatcher");b.divDown.setAttribute("style","width : "+b.downW+"px; height : "+b.downH+"px; left: "+b.downX+"px; top: "+b.downY+"px;");b.scrollManipulator.setAttribute("class","DescartesCatcher");
b.scrollManipulator.setAttribute("style","width : "+b.scrollManipulatorW+"px; height : "+b.scrollManipulatorH+"px;");b.scrollManipulator.style.top=("v"===b.orientation?b.scrollManipulatorLimInf:0)+"px";b.scrollManipulator.style.left=("v"===b.orientation?0:b.scrollManipulatorLimInf)+"px";b.field.setAttribute("type","text");b.field.setAttribute("id",b.id+"scrollbar");b.field.setAttribute("class","DescartesScrollbarField");b.field.setAttribute("style","font-size: "+b.fieldFontSize+"px; width : "+(b.fieldWidth-
2)+"px; height : "+(b.fieldHeight-2)+"px; left: "+b.fieldX+"px; top: 0px;");b.field.value=c;0===b.fieldHeight&&(b.field.style.display="none");b.label.setAttribute("class","DescartesScrollbarLabel");b.label.setAttribute("style","font-size:"+b.fieldFontSize+"px; width: "+b.labelWidth+"px; height: "+b.labelHeight+"px; line-height: "+b.labelHeight+"px; left: 0px; top:"+b.labelY+"px;");b.txtLabel=document.createTextNode(b.name)};a.Scrollbar.prototype.update=function(){k=this.evaluator;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();this.value=this.validateValue(k.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);k.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=
function(){b=this;h=b.ctx;q=e(this.w);f=e(this.h);h.fillStyle="#e0e4e8";h.fillRect(0,0,q,f);h.strokeStyle="#7a8a99";b.down&&(h.fillStyle="#ccdcec",h.fillRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1));h.strokeRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1);b.up&&(h.fillStyle="#ccdcec",h.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));h.strokeRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1);m=4;h.fillStyle="black";h.beginPath();b.orientation===j?(h.moveTo(b.downX+m,b.downH/2),h.lineTo(b.downX+
b.downW-m,m),h.lineTo(b.downX+b.downW-m,b.downH-m),h.moveTo(b.upX+b.upWidth-m,b.downH/2),h.lineTo(b.upX+m,m),h.lineTo(b.upX+m,b.downH-m),h.fill(),b.activeIfValue&&(l=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(l+0.5,0,e(b.scrollManipulatorW),f),h.strokeStyle="#6382bf",h.strokeRect(l+0.5,0,e(b.scrollManipulatorW),f),p=e(b.scrollManipulatorW/2),h.beginPath(),h.moveTo(l+p+0.5-2,3),h.lineTo(l+p+0.5-2,f-3),h.moveTo(l+p+0.5,3),h.lineTo(l+p+0.5,f-3),h.moveTo(l+p+0.5+2,3),h.lineTo(l+p+0.5+2,f-3),h.stroke())):
(h.moveTo(b.downX+b.downW/2,b.downY+b.downH-m),h.lineTo(b.downX+m,b.downY+m),h.lineTo(b.downX+b.downW-m,b.downY+m),h.moveTo(b.upX+b.upWidth/2,b.upY+m),h.lineTo(b.upX+m,b.upY+b.upHeight-m),h.lineTo(b.upX+b.upWidth-m,b.upY+b.upHeight-m),h.fill(),b.activeIfValue&&(l=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(0,l+0.5,q,e(b.scrollManipulatorH)),h.strokeStyle="#6382bf",h.strokeRect(0,l+0.5,q,e(b.scrollManipulatorH)),p=e(b.scrollManipulatorH/2),h.beginPath(),h.moveTo(3,l+p+0.5-2),h.lineTo(q-3,l+p+0.5-2),
h.moveTo(3,l+p+0.5),h.lineTo(q-3,l+p+0.5),h.moveTo(3,l+p+0.5+2),h.lineTo(q-3,l+p+0.5+2),h.stroke()));h.strokeRect(0.5,0.5,q-1,f-1);b.activeIfValue||(h.fillStyle="rgba(240,240,240,"+160/255+")",h.fillRect(0,0,q,f.h))};a.Scrollbar.prototype.validateValue=function(a){k=this.evaluator;n=a.toString();n=parseFloat(n.replace(this.parent.decimal_symbol,"."));isNaN(n)&&(n=0);this.minimo=k.evalExpression(this.min);n<this.minimo&&(this.value=null,n=this.minimo);this.maximo=k.evalExpression(this.max);n>this.maximo&&
(this.value=null,n=this.maximo);s=this.incr;n=0!=s?n*s/s:0;this.fixed&&(n=parseFloat(parseFloat(n).toFixed(k.evalExpression(this.decimals))));return n};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==j?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==j?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&&(g=this.validateValue(a),
g!=this.value&&(this.value=g,this.field.value=this.formatOutputValue(g),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){k=this.evaluator;t=this.scrollManipulatorLimInf;u=this.scrollManipulatorLimSup;r=k.evalExpression(this.min);w=k.evalExpression(this.max);s=this.incr;g=e((this.pos-t)*(w-r)/(u-t)/s)*s+r;g!=this.value&&(this.value=g,this.field.value=this.formatOutputValue(g),
k.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){k=this.evaluator;t=this.scrollManipulatorLimInf;u=this.scrollManipulatorLimSup;r=k.evalExpression(this.min);w=k.evalExpression(this.max);s=this.incr;this.pos=(this.value-r)*(u-t)/(w-r)+t;this.orientation==j?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=
function(){function b(a,c,f,d){clearInterval(w);if((r.up||r.down||r.canvasClick)&&1E-7<Math.abs(r.value-d))c.call(r),a=f?a:30,w=setTimeout(function(){b(a,c,!1,d)},a)}function c(f){f.preventDefault();r.whichButton=a.whichButton(f);"L"==r.whichButton&&r.activeIfValue&&(r.clickPos=r.getCursorPosition(f),r.canvasClick=!0,r.orientation==j?r.clickPos.x<r.prePos?b(t,r.decrease10,!0,r.minimo):b(t,r.increase10,!0,r.maximo):r.clickPos.y<r.prePos?b(t,r.increase10,!0,r.maximo):b(t,r.decrease10,!0,r.minimo))}
function f(a){r.canvasClick=!1;clearInterval(w);a.preventDefault()}function d(a){!0==r.canvasClick&&(r.clickPos=r.getCursorPosition(a),a.preventDefault())}function g(a){r.activeIfValue&&(r.scrollClick=!0,r.initPos=r.getCursorPosition(a),window.addEventListener("mouseup",h),window.addEventListener("mousemove",m),a.preventDefault())}function e(a){r.activeIfValue&&(r.scrollClick=!0,r.initPos=r.getCursorPosition(a),window.addEventListener("touchend",k),window.addEventListener("touchmove",onToucheMove_scrollManipulator),
a.preventDefault())}function h(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("mouseup",h,!1);window.removeEventListener("mousemove",m,!1);a.preventDefault()}function k(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("touchend",k,!1);window.removeEventListener("touchmove",m,!1);a.preventDefault()}function m(a){var b=r.getCursorPosition(a);r.orientation==j?(r.pos=r.prePos-(r.initPos.x-b.x),r.pos<r.scrollManipulatorLimInf&&(r.pos=r.scrollManipulatorLimInf),r.pos>r.scrollManipulatorLimSup&&
(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+r.scrollManipulatorW+"px; height : "+r.h+"px; left: "+r.pos+"px; top: 0px;")):(r.pos=r.prePos-(r.initPos.y-b.y),r.pos>r.scrollManipulatorLimInf&&(r.pos=r.scrollManipulatorLimInf),r.pos<r.scrollManipulatorLimSup&&(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+
r.w+"px; height : "+r.scrollManipulatorH+"px; left: 0px; top: "+r.pos+"px;"));r.changeValueForScrollMovement();a.preventDefault()}function l(c){c.preventDefault();r.whichButton=a.whichButton(c);"L"==r.whichButton&&r.activeIfValue&&(r.up=!0,b(t,r.increase,!0,r.maximo))}function q(c){c.preventDefault();r.whichButton=a.whichButton(c);"L"==r.whichButton&&r.activeIfValue&&(r.down=!0,b(t,r.decrease,!0,r.minimo))}function n(a){r.up=!1;clearInterval(w);a.preventDefault()}function u(a){r.down=!1;clearInterval(w);
a.preventDefault()}function p(a){r.up=!1;clearInterval(w);a.preventDefault();r.draw()}function s(a){r.down=!1;clearInterval(w);a.preventDefault();r.draw()}z=a.hasTouchSupport;var r=this,t=z?500:200,w;r.canvas.oncontextmenu=r.divUp.oncontextmenu=r.divDown.oncontextmenu=r.label.oncontextmenu=r.field.oncontextmenu=r.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&r.changeValue(r.field.value)});z?this.canvas.addEventListener("touchstart",
c):this.canvas.addEventListener("mousedown",c);z||this.divDown.addEventListener("mouseout",u);z?window.addEventListener("touchend",f):window.addEventListener("mouseup",f);z?this.canvas.addEventListener("touchmove",d):this.canvas.addEventListener("mousemove",d);z?this.scrollManipulator.addEventListener("touchstart",e):this.scrollManipulator.addEventListener("mousedown",g);z?this.divUp.addEventListener("touchstart",l):this.divUp.addEventListener("mousedown",l);z?this.divDown.addEventListener("touchstart",
q):this.divDown.addEventListener("mousedown",q);z||this.divUp.addEventListener("mouseout",n);z||this.divDown.addEventListener("mouseout",u);z?window.addEventListener("touchend",p):window.addEventListener("mouseup",p);z?window.addEventListener("touchend",s):window.addEventListener("mouseup",s)};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){E=a.getCursorPosition(b);return{x:E.x-this.offsetLeft,y:E.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Audio=function(e,k){this.controls=!0;this.file="";a.Control.call(this,e,k);var b=this.evaluator.evalExpression(this.expresion);4==b[0].length?(this.w=b[0][2],this.h=b[0][3]):(this.w=100,this.h=
28);this.audio=this.parent.getAudio(this.file);this.autoplay&&(this.audio.setAttribute("autoplay","autoplay"),this.audio.play());this.loop&&this.audio.setAttribute("loop","loop");this.controls&&this.audio.setAttribute("controls","controls");this.audio.setAttribute("style","position: absolute; width: "+this.w+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.addControlContainer(this.audio)};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=
this.x+"px";this.audio.style.top=this.y+"px";this.update()};a.Audio.prototype.update=function(){e=this.evaluator;0<e.evalExpression(this.drawif)?this.audio.style.display="block":(this.audio.style.display="none",this.audio.pause());this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Video=function(e,k){this.controls=!0;this.file="";a.Control.call(this,e,k);var b=this.evaluator.evalExpression(this.expresion);4==b[0].length?(this.w=b[0][2],this.h=
b[0][3]):this.h=this.w=null;this.video=document.createElement("video");this.autoplay&&this.video.setAttribute("autoplay","autoplay");this.loop&&this.video.setAttribute("loop","loop");this.controls&&this.video.setAttribute("controls","controls");this.poster&&this.video.setAttribute("poster",this.poster);this.w&&(this.video.setAttribute("width",this.w),this.video.setAttribute("height",this.h));this.video.setAttribute("style","position: absolute; overflow: hidden; left: "+this.x+"px; top: "+this.y+"px;");
var b=this.file,d=b.lastIndexOf(".");-1!=d&&(b=this.file.substring(0,d));this.video.canPlayType("video/mp4")&&(d=document.createElement("source"),d.setAttribute("src",b+".mp4"),d.setAttribute("type","video/mp4"),this.video.appendChild(d));this.video.canPlayType("video/ogg")&&(d=document.createElement("source"),d.setAttribute("src",b+".ogg"),d.setAttribute("type","video/ogg"),this.video.appendChild(d),d=document.createElement("source"),d.setAttribute("src",b+".ogv"),d.setAttribute("type","video/ogg"),
this.video.appendChild(d));this.video.canPlayType("video/webm")&&(d=document.createElement("source"),d.setAttribute("src",b+".webm"),d.setAttribute("type","video/webm"),this.video.appendChild(d));this.addControlContainer(this.video)};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};a.Video.prototype.update=function(){e=this.evaluator;0<e.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display=
"none",this.video.pause());this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j;a.TextArea=function(e,b){a.Control.call(this,e,b);this.region="interior";this.tabindex=++this.parent.tabindex;if(this.answer){this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var d=this.parent.lessonParser.parseText(this.answer)}this.containerControl=document.createElement("div");this.textArea=document.createElement("div");
this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||void 0==this.text.type?this.rawText||"":this.text.hasFormula?
this.rawText:this.text.toHTML();d&&void 0!=d.type&&!this.text.hasFormula&&(this.answer=d.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){j=this.answer?28:8;e=this.evaluator;this.text=e.getVariable(this.id);this.containerControl.setAttribute("class","DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+
"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=0<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-j)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable",
"true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+this.text+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-j)+"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);e.setVariable(this.id,this.text);this.activeCover.style.display=
this.activeIfValue?"none":"block";this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize()};a.TextArea.prototype.registerMouseAndTouchEvents=function(){function a(d){d.preventDefault();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,j,k,b,d,c,h,f,q,m;a.GraphicControl=function(b,c){k=b.evaluator.parser;this.spaceID="E0";this.text="";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,c);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,q=new a.R2(0,0));this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);
this.registerMouseAndTouchEvents();this.init()};a.extend(a.GraphicControl,a.Control);a.GraphicControl.prototype.init=function(){j=this.evaluator;m=a.hasTouchSupport;var b=j.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];j.setVariable(this.id+".x",this.x);j.setVariable(this.id+".y",this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height):(this.width=2*j.evalExpression(this.size),
this.height=2*j.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";j.setVariable(this.id+".activo",0);this.update()};
a.GraphicControl.prototype.update=function(){j=this.evaluator;this.activeIfValue=0<j.evalExpression(this.activeif);this.drawIfValue=0<j.evalExpression(this.drawif);this.x=j.getVariable(this.id+".x");this.y=j.getVariable(this.id+".y");b=this.space.getAbsoluteX(this.x);d=this.space.getAbsoluteY(this.y);this.active||(this.mouseCacher.style.left=parseInt(b-this._w/2)+"px",this.mouseCacher.style.top=parseInt(d-this._h/2)+"px");this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=
function(){j=this.evaluator;this.drawIfValue&&(h=this.ctx,f=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+0.5,d=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,d),this.image.ready?(this.image.complete&&h.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(d-this.image.height/2)),this.trace&&(f.save(),f.translate(b,d),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())):(h.beginPath(),h.arc(b,d,parseInt(this.width/2),0,e,!1),h.fillStyle=this.colorInt.getColor(),h.fill(),h.lineWidth=1,h.strokeStyle=this.color.getColor(),h.stroke(),this.active&&(h.beginPath(),h.arc(b,d,parseInt(this.width/2)-2,0,e,!1),h.strokeStyle=this.colorInt.borderColor(),h.stroke()),this.trace&&(f.lineWidth=1,f.strokeStyle=this.trace.getColor(),f.beginPath(),f.arc(b,d,parseInt(this.width/2),0,e,!1),f.stroke())))};a.GraphicControl.prototype.evalConstraint=
function(){q.set(this.x,this.y);c=this.newt.findZero(q);this.x=c.x;this.y=c.y;this.evaluator.setVariable(this.id+".x",this.x);this.evaluator.setVariable(this.id+".y",this.y)};a.GraphicControl.prototype.drawText=function(a,b){h=this.ctx;j=this.evaluator;h.fillStyle=this.color.getColor();h.font=this.font;h.textBaseline="alphabetic";h.fillText(j.evalExpression(this.text[0],j.evalExpression(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=
function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.id+".activo",0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(c){c.preventDefault();h.whichButton=a.whichButton(c);
"L"==h.whichButton&&(h.activeIfValue&&h.over)&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.id+".activo",1),h.posAnte=h.getCursorPosition(c),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),window.addEventListener("mouseup",f),window.addEventListener("mousemove",d))}function c(a){a.preventDefault();h.activeIfValue&&(h.parent.deactivateGraphiControls(),
h.click=!0,h.active=!0,h.evaluator.setVariable(h.id+".activo",1),h.posAnte=h.getCursorPosition(a),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),window.addEventListener("touchmove",d),window.addEventListener("touchend",f))}function f(b){b.preventDefault();h.touchId=null;if(h.activeIfValue||h.active)h.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",
d,!1),window.removeEventListener("touchend",f,!1)):(window.removeEventListener("mouseup",f,!1),window.removeEventListener("mousemove",d,!1)),h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),h.mouseCacher.style.left=h.space.getAbsoluteX(h.x)-h._w/2+"px",h.mouseCacher.style.top=h.space.getAbsoluteY(h.y)-h._h/2+"px"}function d(a){a.preventDefault();a.touchId=h.touchId;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.id+".x",h.space.getRelativeX(h.posX));h.evaluator.setVariable(h.id+".y",h.space.getRelativeY(h.posY));h.evaluator.setVariable(h.space.id+".mouse_x",h.x);h.evaluator.setVariable(h.space.id+".mouse_y",h.y);h.parent.updateControls();h.parent.update()}function g(){h.over=!0}function e(){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",
c):(this.mouseCacher.addEventListener("mousedown",b),this.mouseCacher.addEventListener("mouseover",g),this.mouseCacher.addEventListener("mouseout",e));var k};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId){c=0;for(f=a.touches.length;c<f;c++)if(a.touches[c].identifier==a.touchId){b=a.touches[c];break}}else for(var c=0,f=a.touches.length;c<f;c++)if(a.target==a.touches[c].target){b=a.touches[c];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=
a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a,e){var j,k,b,d,c,h,f,q,m,l;if(a.loadLib)return a;var p,n,s,
g,t,u,r,w,z=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,B,x,E,C,A,y,G,F,L,J,v,M,D,H,K,I,O,Q,P,R,N;a.LessonParser=function(b){this.parent=b;this.parser=b.evaluator.parser;this.RTFparser=new a.RTFParser(b.evaluator)};a.LessonParser.prototype.parseButtonsConfig=function(a){var b={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var c=0,f=a.length;c<f;c++)switch(s=a[c][0],g=a[c][1],n=e[s],n){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[n]=
parseInt(g);break;case "about":case "config":case "init":case "clear":b[n]="true"===e[g];break;default:console.log("----- attributo de space no identificado: <"+s+"> valor: <"+g+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){t={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(s=b[c][0],g=b[c][1],n=e[s],n){case "type":case "id":case "cID":case "file":t[n]=g;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":t[n]="true"===e[g];break;
case "bg_display":case "render":t[n]=e[g];break;case "net":case "net10":case "axes":case "text":t[n]="false"===e[g]?"":new a.Color(g,this.parent.evaluator);break;case "x_axis":case "y_axis":t[n]="false"===e[g]?"":g;break;case "O.x":t.OxExpr=g;break;case "O.y":t.OyExpr=g;break;case "image":t.imageSrc=g;break;case "x":p=g;p="%"===p[p.length-1]?(this.parent.container.width*parseFloat(p)/100).toString():g;t.xExpr=this.parser.parse(p);break;case "y":p=g;p="%"===p[p.length-1]?(this.parent.container.height*
parseFloat(p)/100).toString():g;t.yExpr=this.parser.parse(p);break;case "width":p=g;"%"===p[p.length-1]?p=this.parent.container.width*parseFloat(p)/100:(p=parseFloat(g),p!=g&&(p=this.parent.container.width));t.w=p;break;case "height":p=g;"%"===p[p.length-1]?p=this.parent.container.height*parseFloat(p)/100:(p=parseFloat(g),p!=g&&(p=this.parent.container.height));t.h=p;break;case "drawif":t.drawif=this.parser.parse(g);break;case "scale":p=parseFloat(g);p.toString()!=g&&(p=48);t.scale=p;break;case "background":t.background=
new a.Color(g,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+s+"> valor: <"+g+"> -----")}switch(t.type){case "R2":return new a.Space2D(this.parent,t);case "R3":return new a.Space3D(this.parent,t);case "AP":return new a.SpaceAP(this.parent,t);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,t);default:return new a.Space2D(this.parent,t)}};a.LessonParser.prototype.parseControl=function(b){u={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(s=
b[c][0],g=b[c][1],n=e[s],n){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":u[n]=g;break;case "gui":case "region":case "action":case "msg_pos":case "poster":u[n]=e[g];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":u[n]="true"===e[g];break;case "color":case "colorInt":case "trace":u[n]=new a.Color(g,
this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":u[n]=this.parser.parse(g);break;case "constraint":u.constraintExpr=g;break;case "image":u.imageSrc=g;break;case "space":u.spaceID=g;break;case "type":u.type=e[g.trim()];break;case "expresion":u.expresion=this.parser.parse(g.replace(")(",","));break;case "bold":"false"!=e[g]&&(u.bold="bold");break;case "italics":"false"!=e[g]&&(u.italics="italic");break;case "underlined":"false"!=
e[g]&&(u.underlined=!0);break;case "value":var d=g.replace(/&squot;/g,"'");d.match(/^\|/)&&(d="'"+d.substring(1),d.match(/\|$/)&&(d=d.substring(0,d.length-1)+"'"));u.valueExpr=this.parser.parse(d);u.valueExprString=d;break;case "incr":0!=g&&(u.incr=this.parser.parse(g));break;case "exponentialif":u.exponentialif=parseFloat(g);break;case "text":u.rawText=g;for(var d=this.parseText(g),h=0,k=d.length;h<k;h++)d[h]=this.parser.parse(d[h],!1);u.text=d;break;default:h=s.indexOf(".");d=e[s.substring(0,h)];
h=e[s.substring(h+1)];if("parameter"===d&&"font"===h){u.parameterFont=g;break}else if("Explanation"===d&&"font"===h){u.ExplanationFont=g;break}else if("tooltip"===d&&"font"===h){u.tooltipFont=g;break}console.log("----- attributo de control no identificado: <"+s+"> valor: <"+g+"> -----")}if("numeric"===u.type)switch(u.gui){case "spinner":return new a.Spinner(this.parent,u);case "button":return new a.Button(this.parent,u);case "textfield":return new a.TextField(this.parent,u);case "menu":return new a.Menu(this.parent,
u);case "scrollbar":return new a.Scrollbar(this.parent,u);default:return new a.Spinner(this.parent,u)}else{if("video"===u.type)return new a.Video(this.parent,u);if("audio"===u.type)return new a.Audio(this.parent,u);if("graphic"===u.type)return new a.GraphicControl(this.parent,u);if("text"===u.type)return new a.TextArea(this.parent,u)}};a.LessonParser.prototype.parseGraphic=function(b,c,f,d){r={rotateExp:d,parameter:"t"};b=this.split(b);d=0;for(var h=b.length;d<h;d++)switch(s=b[d][0],g=b[d][1],n=e[s],
n){case "type":case "align":r[n]=e[g];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":r[n]="true"===e[g];break;case "color":case "trace":case "fill":case "fillP":case "fillM":case "arrow":r[n]=new a.Color(g,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":r[n]=g;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":r[n]=
this.parser.parse(g);break;case "space":r.spaceID=g;break;case "expresion":"macro"!=r.type?(r.expresion=this.parser.parse(g),r.expresionString=g):r.expresion=g;break;case "text":r.text=this.parseText(g);break;case "file":var k=g.replace(/&squot;/g,"'");"["===k.charAt(0)&&"]"===k.charAt(k.length-1)&&(k=k.substring(1,k.length-1));k.match(z)&&(k="'"+k+"'");r.file=this.parser.parse(k);break;case "border":"false"!=e[g]&&(r.border=new a.Color(g,this.parent.evaluator));break;default:if(void 0!=r.family&&
s.substring(0,r.family.length+1)===r.family+"."){switch(e[s.substring(r.family.length+1)]){case "interval":r.family_interval=this.parser.parse(g);break;case "steps":r.family_steps=this.parser.parse(g)}break}if(void 0!=r.parameter&&s.substring(0,r.parameter.length+1)===r.parameter+"."){switch(e[s.substring(r.parameter.length+1)]){case "interval":r.parameter_interval=this.parser.parse(g);break;case "steps":r.parameter_steps=this.parser.parse(g)}break}console.log("----- attributo del graphic no identificado: <"+
s+"> valor: <"+g+"> -----")}c&&(r.abs_coord=c);f&&(r.background=f);switch(r.type){case "text":return new a.Text(this.parent,r);case "image":return new a.Image(this.parent,r);case "point":return new a.Point(this.parent,r);case "polygon":return new a.Polygon(this.parent,r);case "arc":return new a.Arc(this.parent,r);case "segment":return new a.Segment(this.parent,r);case "arrow":return new a.Arrow(this.parent,r);case "macro":return new a.Macro(this.parent,r);case "curve":return new a.Curve(this.parent,
r);case "equation":return new a.Equation(this.parent,r);case "sequence":return new a.Sequence(this.parent,r);case "fill":return new a.Fill(this.parent,r)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,f,d){r={rotateExp:d,parameter:"t"};b=this.split(b);c=0;for(f=b.length;c<f;c++)switch(s=b[c][0],g=b[c][1],n=e[s],n){case "type":case "model":r[n]=e[g];break;case "background":case "fixed":case "edges":r[n]="true"===e[g];break;case "color":case "backcolor":r[n]=new a.Color(g,this.parent.evaluator);
break;case "type":case "model":r[n]=e[g];break;case "background":case "fixed":case "edges":case "split":r[n]="true"===e[g];break;case "color":case "backcolor":r[n]=new a.Color(g,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":r[n]=this.parser.parse(g);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":r[n]=g;break;case "space":r.spaceID=g;break;case "expresion":"macro"!=
r.type&&"curve"!=r.type&&"surface"!=r.type?(r.expresion=this.parser.parse(g),r.expresionString=g):r.expresion=g.replace(/\\n/g,"");break;case "text":d=this.parseText(g);for(var h=0,k=d.length;h<k;h++)d[h]=this.parser.parse(d[h],!1);r.text=d;break;case "file":d=g.replace(/&squot;/g,"'");"["===d.charAt(0)&&"]"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d.match(/./)&&(d="'"+d+"'");r.file=this.parser.parse(d);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":r[n]=
this.parser.parse(g);break;case "family":case "parameter":case "font":case "name":r[n]=g;break;case "space":r.spaceID=g;break;case "expresion":"macro"!=r.type&&"curve"!=r.type&&"surface"!=r.type?(r.expresion=this.parser.parse(g),r.expresionString=g):r.expresion=g;break;case "text":d=this.parseText(g);h=0;for(k=d.length;h<k;h++)d[h]=this.parser.parse(d[h],!1);r.text=d;break;case "file":d=g.replace(/&squot;/g,"'");"["===d.charAt(0)&&"]"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d.match(/./)&&
(d="'"+d+"'");r.file=this.parser.parse(d);break;default:if(void 0!==r.family&&s.substring(0,r.family.length+1)===r.family+"."){"interval"===e[s.substring(r.family.length+1)]?r.family_interval=this.parser.parse(g):r.family_steps=this.parser.parse(g);break}console.log("----- attributo del graphic3D no identificado: <"+s+"> valor: <"+g+"> -----")}switch(r.type){case "point":return new a.Point3D(this.parent,r);case "segment":return new a.Segment3D(this.parent,r);case "polygon":return new a.Polygon3D(this.parent,
r);case "curve":return new a.Curve3D(this.parent,r);case "triangle":return new a.Triangle3D(this.parent,r);case "face":return new a.Face3D(this.parent,r);case "polireg":return new a.Polireg3D(this.parent,r);case "surface":return new a.Surface3D(this.parent,r);case "text":return new a.Text3D(this.parent,r);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,
r);default:console.log(r.type)}};a.LessonParser.prototype.parseAuxiliar=function(b){w={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(f=b.length;c<f;c++)switch(s=b[c][0],g=b[c][1],n=e[s],n){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":w[n]=g;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "sequence":w[n]="true"===
e[g];break;case "size":case "rows":case "columns":w[n]=this.parser.parse(g);break;case "evaluate":case "event":case "execution":case "msg_pos":case "action":w[n]=e[g];break;default:var d=s.indexOf("."),h=e[s.substring(0,d)],d=e[s.substring(d+1)];if("parameter"===h&&"font"===d){w.parameterFont=g;break}console.log("----- attributo de auxiliar no identificado: <"+s+"> valor: <"+g+"> -----")}w.sequence?new a.Function(this.parent,w):w.constant?(b=new a.Constant(this.parent,w),w.evaluate&&"always"===w.evaluate&&
this.parent.auxiliaries.push(b)):w.algorithm&&w.evaluate?(b=new a.Algorithm(this.parent,w),this.parent.auxiliaries.push(b)):w.array&&!w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Vector(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Matrix(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.event&&")"!=w.id.charAt(w.id.length-1)?this.parent.events.push(new a.Event(this.parent,
w)):")"===w.id.charAt(w.id.length-1)?new a.Function(this.parent,w):new a.Variable(this.parent,w)};a.LessonParser.prototype.parseAction=function(b){B=b.action;x=b.parent;E=b.parameter;if(B)switch(B){case "message":return new a.Message(x,E);case "calculate":return new a.Calculate(x,E);case "openURL":return new a.OpenURL(x,E);case "openScene":return new a.OpenScene(x,E);case "about":return new a.About(x,E);case "config":return new a.Config(x,E);case "init":return new a.Init(x,E);case "clear":return new a.Clear(x,
E);case "animate":return new a.Animate(x,E);case "initAnimation":return new a.InitAnimation(x,E);case "playAudio":return new a.PlayAudio(x,E);default:console.log("----- Accion no soportada aun: <"+B+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var f=0,d=b.length;f<d;f++)switch(s=b[f][0],g=b[f][1],n=e[s],n){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[n]=g;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[n]=
"true"===e[g];break;default:console.log("----- attributo de la animacion no identificado: <"+s+">  <"+g+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(e,n){e=this.split(e);k=j="";b=0;d="#536891";c="white";h="left";f="";q="SansSerif,BOLD,20";m="SansSerif,PLAIN,18";l=void 0;for(var r=0,p=e.length;r<p;r++)switch(s=e[r][0],g=e[r][1],s){case "title":j=g;break;case "subtitle":k=g;break;case "subtitlines":b=g;break;case "bgcolor":""!=g&&(d=(new a.Color(g,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=g&&(c=(new a.Color(g,this.parent.evaluator)).getColor());break;case "align":""!=g&&(h=g);break;case "titleimage":f=g;break;case "titlefont":q=""!=g?a.convertFont(g):a.convertFont(q);break;case "subtitlefont":m=""!=g?a.convertFont(g):a.convertFont(m);break;default:console.log("----- attributo de la pleca no identificado: <"+s+">  <"+g+"> -----")}J=m.substring(0,m.indexOf("px"));J=J.substring(J.lastIndexOf(" "));""!=f&&(v=this.parent.getImage(f),M=v.height);l=document.createElement("div");
l.setAttribute("id","descartesPleca");M?(l.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+h+"; width: "+(n-30)+"px; height: "+(M-16)+"px; background: "+d+"; color: "+c+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),v.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),l.appendChild(v)):l.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
h+"; width: "+(n-30)+"px; background: "+d+"; color: "+c+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");D=document.createElement("div");D.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; overflow: hidden; white-space: nowrap;");D.innerHTML=j;H=document.createElement("div");if(1===parseInt(b)){P=0;K=document.createElement("div");K.innerHTML=k;document.body.appendChild(K);O=J;do O-=P,K.setAttribute("style","padding: 0px; margin: 0px; font: "+
m+"; font-size: "+O+"px; width: "+(n-30)+"px; line-height: "+O+"px;"),I=K.offsetHeight,Q=I/O,P=1;while(1<Q&&8<O);document.body.removeChild(K);H.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; font-size: "+O+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else H.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; line-height: 110%;");H.innerHTML=k;l.appendChild(D);l.appendChild(H);l.imageHeight=M;return l};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");C=[];y=A=0;G=!1;F=0;for(L=!1;A<a.length;)" "===a.charAt(A)&&!G&&A++," "!==a.charAt(A)&&!G&&(G=!0,F=A),"="===a.charAt(A)&&("'"===a.charAt(A+1)&&!L)&&(L=!0,C[y]=[a.substring(F,A)],F=A+2,A+=2),L&&"'"===a.charAt(A)&&(G=L=!1,C[y].push(a.substring(F,A)),y++),"="===a.charAt(A)&&("'"!==a.charAt(A+1)&&!L)&&(C[y]=[a.substring(F,A)],F=A+1,A++,R=a.substring(A).indexOf("="),-1===R?N=R=a.length:(R+=A,N=a.substring(A,R).lastIndexOf(" "),N=-1===N?a.length:N+A),
C[y].push(a.substring(F,N)),y++,G=!1,A=N),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){p=[];p.type="matrix";p.rows=a;p.cols=b;var c;s=0;for(g=b;s<g;s++){c=[];n=0;for(t=a;n<t;n++)c.push(0);p[s]=c}return p}function j(a,b){m=a.rows;l=a.cols;p=e(m,l);var c;for(s=0;s<m;s++)for(n=0;n<l;n++){for(g=c=0;g<l;g++)c+=a[g][s]*
b[n][g];p[n][s]=c}return p}function k(a,b,c){for(var f=e(c.length-1,c.length-1),d=0,h=f.length;d<h;d++)for(var g=0;g<h;g++)f[d][g]=d<a?g<b?c[d][g]:c[d][g+1]:d<b?c[d+1][g]:c[d+1][g+1];return f}function b(a){if(1<a.cols){for(var c=0,f=1,d=0,h=a.cols;d<h;d++)c+=f*a[0][d]*b(k(0,d,a)),f=-f;return c}return a[0][0]}if(a.loadLib)return a;var d=Math.floor,c,h,f,q;a.Node=function(a,b){this.sep="";this.type=a;this.value=b;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null===this.parent?
this:this.parent.getRoot()};a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){c=this.childs.length-1;lastChild=this.childs[c];lastChild.parent=null;this.childs[c]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,c=this.childs.length;b<c;b++)if(this.childs[b].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",
this.value="-",f=new a.Node("compOperator","=="),q=new a.Node("number","0"),f.addChild(this),f.addChild(q),h=this.getRoot(),h.setAllEvaluateFunction(),h):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.setEvaluateFunction=function(){if("number"===this.type)this.evaluate=function(){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,c){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);if(void 0==a&&(c||b.matrices[this.value]))a=b.matrices[this.value];return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1===this.childs[0].childs.length){var c,f;this.evaluate=function(a){c=this.childs[0].childs[0].evaluate(a);
try{return f=a.vectors[this.value][0>c?0:d(c)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var h,g;this.evaluate=function(a){h=this.childs[0].childs[0].evaluate(a);g=this.childs[0].childs[1].evaluate(a);try{return f=a.matrices[this.value][0>h?0:d(h)][0>g?0:d(g)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var q;this.evaluate=function(a){q=[];
for(var b=0,c=this.childs[0].childs.length;b<c;b++)q.push(this.childs[0].childs[b].evaluate(a));return"_Eval_"===this.value?a.evalExpression(a.parser.parse(q[0])):a.functions[this.value].apply(a,q)}}else if("operator"===this.type){var t,C,A;"+"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);C=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==C.type)return t+C;a=t;var b=C;m=a.rows;l=a.cols;p=e(m,l);for(s=0;s<m;s++)for(n=0;n<l;n++)p[n][s]=a[n][s]+b[n][s];return p}:
"-"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);C=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==C.type)return t-C;a=t;var b=C;m=a.rows;l=a.cols;p=e(m,l);for(s=0;s<m;s++)for(n=0;n<l;n++)p[n][s]=a[n][s]-b[n][s];return p}:"*"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);C=this.childs[1].evaluate(a,!0);return"matrix"!==t.type||"matrix"!==C.type?t*C:j(t,C)}:"/"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);C=
this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==C.type)return t/C;a=t;var c;c=C;var f=e(c.length,c.length),d=b(c);if(0===d)c=0;else{var d=1/d,h;if(1<c.length)for(var g=0,m=c.length;g<m;g++){h=d;for(var l=0;l<m;l++)f[l][g]=h*b(k(g,l,c)),h=-h;d=-d}else f[0][0]=d;c=f}a=0===c?e(a.rows,a.cols):j(a,c);return a}:"%"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a);C=this.childs[1].evaluate(a);return t-d(t/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(t=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(t=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===
this.value&&(this.evaluate=function(a){t=this.childs[0].evaluate(a)?1:0;return!t+0});else if("conditional"===this.type)this.evaluate=function(a){t=this.childs[0].evaluate(a);return 0<t?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 y,G;this.evaluate=function(a){y=this.childs.length;A=[];if(1===y&&1===this.childs[0].childs.length&&"(expr)"===this.type)A=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<y;b++){G=[];for(var c=0,f=this.childs[b].childs.length;c<f;c++)G.push(this.childs[b].childs[c].evaluate(a));A[b]=G}return A}}else if("asign"===this.type){var F,L,J,v,M,D;this.evaluate=function(a){F=this.childs[0];L=this.childs[1];1===F.childs.length&&"square_bracket"===F.childs[0].type?
(c=F.childs[0].childs,1===c.length?(J=c[0].evaluate(a),J=0>J?0:d(J),a.vectors[F.value][J]=L.evaluate(a)):2===c.length&&(v=c[0].evaluate(a),M=c[1].evaluate(a),v=0>v?0:d(v),M=0>M?0:d(M),a.matrices[F.value][v]||(a.matrices[F.value][v]=[]),a.matrices[F.value][v][M]=L.evaluate(a))):(D=L.evaluate(a),D.type?a.matrices[F.value]=D:a.variables[F.value]=D)}}};var m,l,p,n,s,g,t;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:
"");for(var b=0,c=this.childs.length;b<c;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h,f,q,m=/^\s+/,l=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,p=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,n=/^==|^!=|^<=|^<|^>=|^>|^#/,s=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,g=/^=/,t=/^[\?\:]/,u=/^[\+\-\*\/\%\^]/,r=/^\[|^\]/,w=/^\(|^\)/,z=/^,/,B=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=
function(a){function x(a,d,h){j.push({type:a,value:d});c=c.slice(h);b+=h;f++;q=a}if(e=a)a=a.replace(/\\u(\S+) /g,function(a,b){return String.fromCharCode(parseInt(b,16))}),a=a.replace(/\&sup(.+);/g,"^$1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*","'","g").replace("*|","'","g")),a.match(/\=\|/g)&&(a=a.replace("|","'","g"));j=[];k=!1;b=0;c=a;f=0;for(q="";a&&b<a.length;)if(k=b,"'"==c[0]){for(h=1;"'"!=c[h];)if(h<c.length)h++;else{console.log(">Error, unknown symbol: ["+c+"], in the string <<"+
e+">>");return}d=c.substring(1,h);x("string",d,d.length+2)}else if(d=c.match(m))c=c.slice(d[0].length),b+=d[0].length,f++;else if(d=c.match(l))"number"===q&&j.push({type:"operator",value:"*"}),x("identifier",d[0],d[0].length);else if(d=c.match(p))x("number",d[0],d[0].length);else if(d=c.match(n)){var y=d[0];"#"==y&&(y="!=");x("compOperator",y,d[0].length)}else if(d=c.match(s))y=d[0],"||"==y?y="|":"&&"==y?y="&":"~"==y&&(y="!"),x("boolOperator",y,d[0].length);else if((d=c.match(g))&&!c.match(/^==/))x("asign",
d[0],d[0].length);else if(d=c.match(t))x("conditional",d[0],d[0].length);else if(d=c.match(u))x("operator",d[0],d[0].length);else if(d=c.match(r))x("square_bracket",d[0],d[0].length);else if(d=c.match(w))x("parentheses",d[0],d[0].length);else if(d=c.match(z))x("separator",d[0],d[0].length);else if(d=c.match(B))x("final_of_expresion",d[0],d[0].length);else if(k==b){console.log("Error, simbolo no conocido: ["+c+"], en la cadena <<"+e+">>");return}return j};var x,E=/rnd|pi|e|Infinity|-Infinity|sqr|sqrt|ra\u00edz|exp|log|log10|abs|ent|sgn|ind|sin|sen|cos|tan|cot|sec|csc|sinh|senh|cosh|tanh|coth|sech|csch|asin|asen|acos|atan|min|max/;
a.Tokenizer.prototype.flatTokens=function(a,b){a=a||[];b=b||"";x="";for(var c=0,f=a.length;c<f;c++)x="string"==a[c].type?x+"&squot;"+a[c].value+"&squot;":"identifier"==a[c].type&&!a[c].value.match(E)?x+b+a[c].value:x+a[c].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,c){this.vectors[a][b]=c};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,b,c,f){this.matrices[a][b][c]=f};a.Parser.prototype.getMatrix=function(a){this.matrices.hasOwnProperty(a)||(this.matrices[a]=[[0,0,0],[0,0,0],[0,0,0]]);return this.matrices[a]};
a.Parser.prototype.setFunction=function(a,b){this.functions[a]=b};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var e,j,k,b,d,c,h,f,q,m,l,p;a.Parser.prototype.parse=function(n,s){(k=this.tokenizer.tokenize(n))||(k=[]);b=null;s=!s||!1;e=f=h=c=0;for(j=k.length;e<j;e++)if(q=k[e],m=q.value,l=q.type,"identifier"===l&&(e+1<j&&"parentheses"===k[e+1].type&&"("===k[e+1].value?this.getFunction(m):e+1<j&&"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&&s&&(l="compOperator",m="=="),"asign"===l)if(d=new a.Node(l,m),null!=b)if("identifier"===b.type)b.parent&&b.parent.replaceLastChild(d),d.addChild(b),b=d,s=!0;else if("square_bracket"===b.type)d.addChild(b.parent),b=d,s=!0;else{d.type="compOperator";d.value="==";for(s=!0;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=
b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error1: en la expresion <<"+n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("parentheses"===l&&"("===m||"square_bracket"===l&&"["===m)if(d=new a.Node(l,m),"("===m&&c++,"["===m&&h++,null===b)"("===m&&(new a.Node("(expr)","(expr)")).addChild(d),"["===m&&(new a.Node("[expr]","[expr]")).addChild(d),b=d;else if("operator"===b.type||"boolOperator"===b.type||"compOperator"===b.type||"conditional"===b.type||
"asign"===b.type)b.addChild(d),b=d;else if("sign"===b.type)b.addChild(d),b=d;else if("parentheses"===b.type&&"("===b.value)b.addChild(d),b=d;else if("square_bracket"===b.type&&"["===b.value)b.addChild(d),b=d;else if("parentheses"===b.type&&"()"===b.value)b.parent.addChild(d),b=d;else if("square_bracket"===b.type&&"[]"===b.value)b.parent.addChild(d),b=d;else if("identifier"===b.type)b.addChild(d),b=d;else{console.log("Error2: en la expresion <<"+n+">>, en el token ["+e+"] {valor: "+m+", tipo: "+l+
"}");break}else if("parentheses"===l&&")"===m)if(c--,null===b)console.log("Error3: en la expresion <<"+n+">>, 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 <<"+n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else if("square_bracket"===l&&"]"===m)if(h--,null===b)console.log("Error5: en la expresion <<"+n+">>, 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 <<"+n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else if("number"===l||"string"===l||"identifier"===l)if(d=new a.Node(l,m),null===b)b=d;else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"parentheses"===b.type&&"("===b.value||"square_bracket"===b.type&&"["===b.value||"sign"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(d),b=d;else{console.log("Error7: en la expresion <<"+
n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("operator"===l||"compOperator"===l||"boolOperator"===l)if(d=new a.Node(l,m),null===b)if("-"===m||"+"===m)d.type="sign",d.value="sign"+m,b=d;else if("!"===m)b=d;else{console.log("Error8: en la expresion <<"+n+">>, 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)d.type="sign",d.value="sign"+m;b.addChild(d);b=d}else if("number"===b.type||"parentheses"===b.type&&"()"===b.value||"square_bracket"===b.type&&"[]"===b.value||"string"===b.type||"identifier"===b.type||"conditional"===b.type||"asign"===b.type){for(;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error9: en la expresion <<"+
n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else if("conditional"===l)if(d=new a.Node(l,m),null!=b)if("?"===d.value){for(f++;b.parent&&this.getPrecedence(b.parent.value)>this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{for(f--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"===b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}}else{console.log("Error11: en la expresion <<"+
n+">>, 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 <<"+n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}else{console.log("Error13: en la expresion <<"+n+">>, en el token {valor: "+m+", tipo: "+l+"}");break}0<c&&alert("Error, faltan parentesis por cerrar: "+n);0>c&&alert("Error, faltan parentesis por abrir: "+n);0<h&&alert("Error, faltan square bracketss por cerrar: "+
n);0>h&&alert("Error, faltan square bracketss por abrir: "+n);0!=f&&alert("Error, condicional incompleta: "+n);(p=b?b.getRoot():null)&&p.setAllEvaluateFunction();return p};a.Parser.prototype.getPrecedence=function(a){switch(a){case "=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;
case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "^":return 8;case "%":return 8;default:return 9}};a.Parser.prototype.registerDefaultValues=function(){this.variables.rnd=Math.random;this.variables.pi=Math.PI;this.variables.e=Math.E;this.variables.Infinity=Infinity;this.variables["-Infinity"]=-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=Math.sqrt;this.functions.exp=Math.exp;
this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=function(a){return 1/Math.sin(a)};
this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=Math.asin;this.functions.acos=
Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;var b=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){b.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(c,f,d){return a.esCorrecto(c,f,b.evaluator,d)};this.functions.escorrecto=function(c,f,d){return a.escorrecto(c,f,b.evaluator,d)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",
name:a,value:b},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*")})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Evaluator=function(e){this.parent=e;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices};
a.Evaluator.prototype.setVariable=function(a,e){this.variables[a]=e};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,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,d){k=0>k?0:e(k);b=0>b?0:e(b);this.matrices[a][k][b]=d};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,j=!1;a.RTFNode=function(a,b,f,d){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=f;this.style=d;this.styleString=d.toString();this.color=d.textColor;this.underline=d.textUnderline;this.overline=
d.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;case "superIndex":this.draw=this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=
this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;break;case "matrix":this.draw=this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=
this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":this.draw=this.drawComponentSpace}};a.RTFNode.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.children.push(a)};var k=0,b=0,d=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var c=0,h=this.children.length;c<
h;c++)this.children[c].getTextMetrics()}else if("textLineBlock"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("newLine"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;this.width=f.width;this.height=f.height}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 c=this.value,q;"string"!=typeof this.value&&(h=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),q=void 0==this.fixed?j:this.fixed,c=this.evaluator.evalExpression(this.value,h,q),parseFloat(c)==c&&(c=parseFloat(c).toFixed(h),c=q?c:parseFloat(c),c=c.toString().replace(".",this.decimal_symbol)),c+=" ");this.width=a.getTextWidth(c,this.styleString);this.height=f.height}else if("formula"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType)c=a.getFontMetrics(this.styleString),this.baseline=c.baseline,this.descent=c.descent,this.ascent=c.ascent,this.width=a.getTextWidth(this.value,this.styleString),this.height=c.height,this.clickCacher=document.createElement("div"),this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px;");else if("superIndex"==this.nodeType)this.spaceWidth=
a.getTextWidth(" ",this.styleString),h=k,f=b,h=d,c=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=c.ascent,this.descent=c.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),c=h/2-f+this.height,this.superIndexPos=c-this.ascent,this.ascent=c,this.descent=f,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),h=k,f=b,c=a.getFontMetrics(this.styleString),
this.getBlockMetric(),0>this.height&&(this.ascent=c.ascent,this.descent=c.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),this.subIndexPos=f+1,this.ascent=h,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("fraction"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=b;h=d;q=this.children[0];var m=this.children[1],c=a.getFontMetrics(q.styleString);q.getBlockMetric();m.getBlockMetric();
0>q.height&&(q.height=c.height,q.width=this.spaceWidth);0>m.height&&(m.height=c.height,m.width=this.spaceWidth);this.height=q.height+m.height-1;this.ascent=q.height+h/2-f;this.descent=this.height-this.ascent;this.baseline=this.ascent;this.width=Math.max(q.width,m.width)+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){q=new a.RTFNode(this.evaluator,"","radicand",f);c=0;for(h=this.children.length;c<h;c++)q.addChild(this.children[c]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",f);this.children[1]=q}f=this.children[0];c=this.children[1];f.getBlockMetric();c.getBlockMetric();this.ascent=c.height/2<f.height?c.height/2+f.height+2-c.descent:c.ascent+
4;this.descent=c.descent;this.baseline=this.ascent;this.height=this.ascent+this.descent;this.width=f.width+c.width+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=this.children[0],h=this.children[1],q=this.children[2],f.getBlockMetric(),h.getBlockMetric(),q.getBlockMetric(),-1==f.ascent&&(m=a.getFontMetrics(f.styleString),f.ascent=m.ascent,f.descent=m.descent,f.height=m.height),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,
h.descent=m.descent,h.height=m.height),c=a.getFontMetrics(this.styleString),this.ascent=c.height+h.height>q.ascent?c.height-c.descent+h.height:q.ascent,this.descent=f.height>q.descent?f.height+c.descent:q.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,c=this.style.clone(),c.fontType="Times New Roman",c.Bold="bold",c=c.toString(),c=a.getTextWidth(String.fromCharCode(8721),c),this.width=Math.max(f.width,h.width,c)+Math.max(q.width,this.spaceWidth)+this.spaceWidth;else if("integral"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=this.children[0],h=this.children[1],q=this.children[2],f.getBlockMetric(),h.getBlockMetric(),q.getBlockMetric(),-1==f.ascent&&(m=a.getFontMetrics(f.styleString),f.ascent=m.ascent,f.descent=m.descent,f.height=m.height),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,h.descent=m.descent,h.height=m.height),c=a.getFontMetrics(this.styleString),this.ascent=c.height+h.height>q.ascent?c.height-c.descent+h.height:q.ascent,
this.descent=f.height>q.descent?f.height+c.descent:q.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,c=this.style.clone(),c.fontSize*=1.5,c.fontType="Times New Roman",c.Bold="bold",c=c.toString(),c=a.getTextWidth(String.fromCharCode(8747),c),this.width=Math.max(f.width,h.width,c)+Math.max(q.width,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=this.children[0],h=this.children[1],q=this.children[2],c=a.getFontMetrics(this.styleString),
f.getBlockMetric(),h.getBlockMetric(),q.getBlockMetric(),-1==f.ascent&&(m=a.getFontMetrics(f.styleString),f.ascent=m.ascent,f.descent=m.descent,f.height=m.height),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,h.descent=m.descent,h.height=m.height),-1==q.ascent&&(m=a.getFontMetrics(q.styleString),q.ascent=m.ascent,q.descent=m.descent,q.height=m.height),this.ascent=q.ascent,this.descent=Math.max(c.height,q.descent),this.baseline=this.ascent,this.height=this.ascent+this.descent,
c=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==f.width&&(f.width=this.spaceWidth),0==h.width&&(h.width=this.spaceWidth),0==q.width&&(q.width=this.spaceWidth),this.width=h.width+f.width+q.width+c+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=a.getFontMetrics(this.styleString);f=b;q=c.ascent;for(var m=c.descent,l=c.height,p=this.spaceWidth,n,s,c=0,h=this.children.length;c<h;c++)this.children[c].getBlockMetric(),n=this.children[c].height,
s=this.children[c].width,l<n&&(l=n,q=this.children[c].ascent,m=this.children[c].descent),p<s&&(p=s);this.childWidth=p+2*this.spaceWidth;this.childHeight=l;this.childAscent=q;this.childDescent=m;this.height=this.rows*l;this.ascent=this.height/2+f;this.descent=this.height-this.ascent;this.width=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=a.getFontMetrics(this.styleString);f=b;q=c.ascent;m=c.descent;l=c.height;
p=this.spaceWidth;c=0;for(h=this.children.length;c<h;c++)this.children[c].getBlockMetric(),n=this.children[c].height,s=this.children[c].width,l<n&&(l=n,q=this.children[c].ascent,m=this.children[c].descent),p<s&&(p=s);this.childWidth=p+2*this.spaceWidth;this.childHeight=l;this.childAscent=q;this.childDescent=m;this.height=this.parts*l;this.ascent=this.height/2+f;this.descent=this.height-this.ascent;this.width=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.width=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.height=f.height):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),this.height=this.ascent=this.descent=this.baseline=0,this.width=this.componentNumCtrl.w):"componentSpace"==this.nodeType?
(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentSpace=this.evaluator.parent.getSpaceByCId(this.value),this.height=this.ascent=this.descent=this.baseline=0,this.width=this.componentSpace.w):console.log("Element i=unknown",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.width=0;for(var a=-1,h=-1,f,e=0,m=this.children.length;e<m;e++){f=this.children[e];f.getTextMetrics();childAscent=f.ascent;childDescent=f.descent;this.width+=f.width;var j=childDescent;f=f.height;
k=childAscent;b=j;d=f;h<childAscent&&(h=childAscent);a<childDescent&&(a=childDescent)}this.ascent=h;this.descent=a;this.baseline=this.ascent;this.height=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,f,d,k,l,p){this.stableWidth||(this.getTextMetrics(),e=d,j=k);p=p?-this.children[0].ascent:0;k=d=0;for(l=this.children.length;k<l;k++)0<k&&(d+=this.children[k-1].height),this.children[k].draw(a,b+0,f+p+d)};a.RTFNode.prototype.drawTextLineBlock=function(b,d,f){for(var e=0,k=0,
j=this.children.length;k<j;k++)0<k&&(e+=this.children[k-1].width,"formula"==this.children[k-1].nodeType&&(e+=2*a.getTextWidth(" ",this.children[k].styleString))),this.children[k].draw(b,d+e,f+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,f){for(var d=0,e=0,k=this.children.length;e<k;e++)0<e&&(d+=this.children[e-1].width),this.children[e].draw(a,b+this.spaceWidth+d,f)};a.RTFNode.prototype.drawText=function(a,b,f){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign=
"start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,f);if(this.underline){var d="bold"==this.style.textBold,e=d?1:0.5;a.lineWidth=d?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(f+this.descent/2)+e);a.lineTo(b-1+this.width,parseInt(f+this.descent/2)+e);a.stroke()}this.overline&&(e=(d="bold"==this.style.textBold)?2:1.5,a.lineWidth=d?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(f-this.ascent)+e),a.lineTo(b-1+this.width,
parseInt(f-this.ascent)+e),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,d,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?j:this.fixed,p=this.evaluator.evalExpression(this.value,m,l);parseFloat(p).toString()===p.toString()&&(p=l?parseFloat(p).toFixed(m):parseFloat(parseFloat(p).toFixed(m)),p=(""+p).replace(".",this.decimal_symbol));null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;
b.textAlign="start";b.textBaseline="alphabetic";this.width=a.getTextWidth(p,this.styleString);b.fillText(p,k+d,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+d-1,parseInt(f+this.descent/2)+l),b.lineTo(k+d-1+this.width,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+
d-1,parseInt(f-this.ascent)+l),b.lineTo(k+d-1+this.width,parseInt(f-this.ascent)+l),b.stroke());this.width+=2*k};a.RTFNode.prototype.drawHyperlink=function(a,b,d){a.save();this.click?(a.fillStyle="red",a.strokeStyle="red"):(a.fillStyle="blue",a.strokeStyle="blue");a.font=this.styleStr;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,d);var e="bold"==this.style.textBold,k=e?1:0.5;a.linew=e?2:1;a.beginPath();a.moveTo(b-1,parseInt(d+this.descent/2)+k);a.lineTo(b-1+this.w,parseInt(d+
this.descent/2)+k);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,d){var e=Math.floor(this.spaceWidth);this.children[0].draw(a,b,Math.floor(d+this.children[1].descent-this.children[1].height/2-this.children[0].descent));this.children[1].draw(a,b+1.5*e+this.children[0].width,d);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b,Math.floor(d+this.children[1].descent-this.children[1].height/2));a.lineTo(b+this.children[0].width,Math.floor(d+this.children[1].descent-
this.children[1].height/2));a.lineTo(b+this.children[0].width+0.5*e,d+this.children[1].descent);a.lineTo(b+this.children[0].width+1*e,d-this.children[1].ascent);a.lineTo(b+this.children[0].width+2*e+this.children[1].width,d-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,b,d){this.children[0].draw(a,b+(this.width-this.children[0].width)/2,d-this.ascent);this.children[1].draw(a,b+(this.width-this.children[1].width)/2,d-this.ascent+this.children[0].height-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(d-this.ascent+this.children[0].height)+0.5);a.lineTo(b-e+this.width-1,parseInt(d-this.ascent+this.children[0].height)+0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,d){for(var e=0,k=0,j=this.children.length;k<j;k++)0<k&&(e+=this.children[k-1].width),this.children[k].draw(a,b+e,d+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,d){for(var e=0,k=0,j=this.children.length;k<
j;k++)0<k&&(e+=this.children[k-1].width),this.children[k].draw(a,b+e,d+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,d){for(var e=0,k=0,j=this.children.length;k<j;k++)0<k&&(e+=this.children[k-1].width),this.children[k].draw(a,b+e,d-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,d,f){var e=a.getFontMetrics(this.styleString),k=" "+String.fromCharCode(8594),j=a.getTextWidth(k,this.styleString);this.children[0].draw(b,d,f+e.descent+this.children[0].ascent);this.children[1].draw(b,
d+this.children[0].width+j,f+e.descent+this.children[1].ascent);this.children[2].draw(b,d+j+this.children[0].width+this.children[1].width,f);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",d+this.children[0].width,f);b.fillText(k,d+this.children[0].width,f+e.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,d,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),j=a.getFontMetrics(e),p=Math.max(this.children[0].width,this.children[1].width,Math.floor(1.5*k));this.children[0].draw(b,d+k,f+j.descent+this.children[0].ascent);this.children[1].draw(b,d+k+this.spaceWidth/2,f-this.ascent+this.children[1].ascent);this.children[2].draw(b,d+p+k,f);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),d,f+
j.descent/2)};a.RTFNode.prototype.drawSum=function(b,d,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),j=a.getFontMetrics(this.styleString),p=Math.max(this.children[0].width,this.children[1].width,k);this.children[0].draw(b,d+(p-this.children[0].width)/2,f+j.descent+this.children[0].ascent);this.children[1].draw(b,d+(p-this.children[1].width)/2,f-j.ascent-this.children[1].descent);this.children[2].draw(b,d+p,f);
null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),d+Math.floor((p-k)/2),f-5)};a.RTFNode.prototype.drawMatrix=function(a,b,d){for(var e,k,j=0,p=this.children.length;j<p;j++)e=j%this.columns,k=Math.floor(j/this.columns),this.children[j].draw(a,2*this.spaceWidth+b+e*this.childWidth,d-this.ascent+this.childAscent+k*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(b+
this.spaceWidth)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,d+this.descent+0.5);a.lineTo(Math.floor(b+this.spaceWidth)+0.5,d+this.descent+0.5);a.moveTo(Math.floor(b+this.width-this.spaceWidth)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.width-this.spaceWidth/2)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.width-this.spaceWidth/2)-0.5,d+this.descent+0.5);a.lineTo(Math.floor(b+this.width-this.spaceWidth)-
0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,b,d){for(var e=0,k=this.children.length;e<k;e++)this.children[e].draw(a,b+this.spaceWidth/4,d-this.ascent+this.childAscent+e%this.parts*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(b+this.spaceWidth/3)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/6)+0.5,d-this.ascent+0.5+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(b+this.spaceWidth/
6)+0.5,d+this.descent-this.height/2-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(b+0.5,d+this.descent-this.height/2);a.lineTo(Math.floor(b+this.spaceWidth/6)+0.5,d+this.descent-this.height/2+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(b+this.spaceWidth/6)+0.5,d+this.descent+0.5-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(b+this.spaceWidth/3)+0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,b,d){a.lineWidth=1;null!=this.color&&(a.strokeStyle=
this.color,a.fillStyle=this.color);a.beginPath();"("==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText("(",b,d)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",b+this.spaceWidth,d)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,b+this.width/2,d))};a.RTFNode.prototype.drawGenericBlock=function(a,b,d){for(var e=0,k=0,j=this.children.length;k<j;k++)0<
k&&(e+=this.children[k-1].width),this.children[k].draw(a,b+e,d)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,d){this.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+b+","+(d-this.parent.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,d){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b+"");this.componentSpace.yExpr=this.evaluator.parser.parse(d-this.parent.ascent+
"")};a.RTFNode.prototype.draw=function(){console.log(">>> Dibujo desconocido ",this.nodeType)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=String.fromCharCode,j,k,b,d,c,h,f,q,m,l,p;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/\&quote;/g,"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];
j=[];k=a.length;j=[];b="";c=d=0;f=a.charAt(0);q=!1;for(m="text";d<k;)h=f,f=a.charAt(d+1),q?"\\"===f||"{"===f||"}"===f||" "===f||";"===f?(q=!1,b+=h," "===f&&(d++,f=a.charAt(d+1)),(l=b.match(/^\'([0-9a-f]{2})/))?(p="","text"===m&&(p=j.pop().value),b=p+=e(parseInt(l[1],16))+b.substring(3)):(l=b.match(/^u[0-9]+/))?(p="","text"===m&&(p=j.pop().value),b=p+=e(l[0].substring(1))):(j.push({type:"controlWord",value:b}),m="controlWord",b="")):b+=h:"\\"===h?(q=!0,""!==b&&(j.push({type:"text",value:b}),m="text"),
b=""):"{"===h?(c++,""!==b&&j.push({type:"text",value:b}),b="",j.push({type:"openBlock",value:c}),m="openBlock"):"}"===h?(""!==b&&j.push({type:"text",value:b}),b="",j.push({type:"closeBlock",value:c}),m="closeBlock",c--):""===b&&" "===h&&"controlWord"===m?m="text":b+=h,d++;""!==b&&j.push({type:"text",value:b});return j};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h,f,q,m,l,p,n,s,g,t,u,r,w,z,B,x,E,C,A,y,G,F,L,J;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=
new a.RTFTokenizer};a.RTFParser.prototype.parse=function(v){v=e=this.tokenizer.tokenize(v);for(var M=[],D=!1,H=!1,K=[],I=0,O=v.length;I<O;I++){"openBlock"==v[I].type&&K.push(v[I].value);"closeBlock"==v[I].type&&(K.pop(),0>=K.length&&(D=!1));if("controlWord"==v[I].type&&("expr"==v[I].value||"decimals"==v[I].value))H=!0;"controlWord"==v[I].type&&"mjaformula"==v[I].value&&(D=!0);if("text"==v[I].type&&D&&!H){for(var Q=0,P=v[I].value,R="",N=0,T=P.length;N<T;N++)if("("==P.charAt(N)||")"==P.charAt(N)||"+"==
P.charAt(N)||"-"==P.charAt(N)||"*"==P.charAt(N)||"="==P.charAt(N))R=P.substring(Q,N),""!=R&&M.push({type:"text",value:R}),M.push({type:P.charAt(N),value:P.charAt(N)}),Q=N+1;R=P.substring(Q,N);""!=R&&M.push({type:"text",value:R})}else M.push(v[I]),"text"==v[I].type&&H&&(H=!1)}e=M;j={};b=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(k=e[0].value;"closeBlock"!=e[b].type&&e[b].value!=k;)j[e[b].value]=e[b+2].value.substring(0,e[b+2].value.length-1),b+=3;b++}d={};c=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;)h=parseInt(e[b++].value.substring(3)).toString(16),f=parseInt(e[b++].value.substring(5)).toString(16),q=parseInt(e[b++].value.substring(4)).toString(16),";"===e[b].value&&b++,d[c++]="#"+(2>h.length?"0"+h:h)+(2>f.length?"0"+f:f)+(2>q.length?"0"+q:q);b++}m=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");l=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");m.addChild(l);s=n=p=null;z=w=r=u=t=g=!1;B=[new a.FontStyle(20,
"Arial","","",!1,!1,null)];x=B[0];E=!0;A=C=-1;y=[];J=L=F=G=!1;v=b;for(M=e.length;v<M;v++)if("controlWord"==e[v].type&&j[e[v].value])x.fontType=j[e[v].value];else if("controlWord"==e[v].type&&e[v].value.match(/^fs(\d+)/))x.fontSize=parseInt(e[v].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==e[v].type&&"b"==e[v].value)x.textBold="bold";else if("controlWord"==e[v].type&&"b0"==e[v].value)x.textBold="";else if("controlWord"==e[v].type&&"i"==e[v].value)x.textItalic="italic";else if("controlWord"==
e[v].type&&"i0"==e[v].value)x.textItalic="";else if("controlWord"==e[v].type&&"ul"==e[v].value)x.textUnderline=!0;else if("controlWord"==e[v].type&&"ulnone"==e[v].value)x.textUnderline=!1;else if("controlWord"==e[v].type&&"ol"==e[v].value)x.textOverline=!0;else if("controlWord"==e[v].type&&"olnone"==e[v].value)x.textOverline=!1;else if("controlWord"==e[v].type&&e[v].value.match(/^cf(\d+)/))x.textColor=d[parseInt(e[v].value.substring(2))];else if("openBlock"==e[v].type)C=e[v].value,x=x.clone(),B.push(x),
y.push(null);else if("closeBlock"==e[v].type)e[v].value==A&&(A=-1,g=!1,l=l.parent),B.pop(),x=B[B.length-1],y.pop();else if("controlWord"==e[v].type&&"par"==e[v].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[v].type&&"mjaformula"==e[v].value)G=!0,A=C,g=!0,m=new a.RTFNode(this.evaluator,"","formula",
x.clone()),l.addChild(m),l=m,y[y.length-1]=m;else if("controlWord"==e[v].type&&("fraction"==e[v].value||"radicand"==e[v].value||"radical"==e[v].value||"what"==e[v].value||"sum"==e[v].value||"integral"==e[v].value||"limit"==e[v].value))D=y[y.length-2].style.clone(),m=new a.RTFNode(this.evaluator,"",e[v].value,D),y[y.length-2].addChild(m),y[y.length-1]=m;else if("controlWord"==e[v].type&&"index"==e[v].value||"to"==e[v].value||"from"==e[v].value)D=y[y.length-2].style.clone(),D.fontSize=parseInt(D.fontSize-
0.2*D.fontSize),8>D.fontSize&&(D.fontSize=8),m=new a.RTFNode(this.evaluator,"",e[v].value,D),y[y.length-2].addChild(m),y[y.length-1]=m;else if("controlWord"==e[v].type&&("num"==e[v].value||"den"==e[v].value))D=y[y.length-2].style.clone(),D.fontSize=Math.round(D.fontSize-0.1*D.fontSize),8>D.fontSize&&(D.fontSize=8),"num"==e[v].value?m=new a.RTFNode(this.evaluator,"","numerator",D):"den"==e[v].value&&(m=new a.RTFNode(this.evaluator,"","denominator",D)),y[y.length-2].addChild(m),y[y.length-1]=m;else if("controlWord"==
e[v].type&&("subix"==e[v].value||"supix"==e[v].value))D=y[y.length-2].style.clone(),D.fontSize=Math.floor(D.fontSize-D.fontSize/3),8>D.fontSize&&(D.fontSize=8),"subix"==e[v].value?m=new a.RTFNode(this.evaluator,"","subIndex",D):"supix"==e[v].value&&(m=new a.RTFNode(this.evaluator,"","superIndex",D)),m.originalStyle=y[y.length-2].style.clone(),y[y.length-2].addChild(m),y[y.length-1]=m;else if("controlWord"==e[v].type&&("defparts"==e[v].value||"matrix"==e[v].value||"element"==e[v].value))D=y[y.length-
2].style.clone(),m=new a.RTFNode(this.evaluator,"",e[v].value,D),y[y.length-2].addChild(m),y[y.length-1]=m,"defparts"==e[v].value?s=m:"matrix"==e[v].value&&(n=m);else if("controlWord"==e[v].type&&"parts"==e[v].value)z=!0;else if("text"==e[v].type&&z)s.parts=parseInt(e[v].value),z=!1;else if("controlWord"==e[v].type&&"rows"==e[v].value)r=!0;else if("text"==e[v].type&&r)n.rows=parseInt(e[v].value),r=!1;else if("controlWord"==e[v].type&&"columns"==e[v].value)w=!0;else if("text"==e[v].type&&w)n.columns=
parseInt(e[v].value),w=!1;else if("controlWord"==e[v].type&&"expr"==e[v].value)E=!1,t=!0;else if("controlWord"==e[v].type&&"decimals"==e[v].value)u=!0;else if("text"==e[v].type&&u)p.decimals=this.evaluator.parser.parse(parseInt(e[v].value)+""),u=!1;else if("controlWord"==e[v].type&&"fixed1"==e[v].value)p.fixed=!0;else if("controlWord"==e[v].type&&"fixed0"==e[v].value)p.fixed=!1;else if(!("controlWord"==e[v].type&&"component"==e[v].value))if("controlWord"==e[v].type&&"NumCtrl"==e[v].value)F=!0;else if("controlWord"==
e[v].type&&"Space"==e[v].value)L=!0;else if("controlWord"==e[v].type&&"hyperlink"==e[v].value)J=!0;else if("text"==e[v].type&&J){textContent=e[v].value.split("|")[0];D=x.clone();m=new a.RTFNode(this.evaluator,textContent,"hyperlink",D);if("textLineBlock"!=l.nodeType)for(l=l.parent;"textLineBlock"!=l.nodeType;)l=l.parent;l.addChild(m);J=!1}else if("text"==e[v].type&&F)m=new a.RTFNode(this.evaluator,e[v].value,"componentNumCtrl",x.clone()),l.addChild(m),F=!1;else if("text"==e[v].type&&L)m=new a.RTFNode(this.evaluator,
e[v].value,"componentSpace",x.clone()),l.addChild(m),L=!1;else if("text"==e[v].type&&t)D=y[y.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[v].value),m=new a.RTFNode(this.evaluator,textContent,"dynamicText",D),y[y.length-2].addChild(m),p=y[y.length-1]=m,t=!1;else if("text"==e[v].type&&!t&&!g){textContent=e[v].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[v].type&&!t&&g)textContent=e[v].value,m=new a.RTFNode(this.evaluator,textContent,"text",y[y.length-1].style.clone()),y[y.length-1].addChild(m);else if("("==e[v].type||")"==e[v].type)D=y[y.length-1].style.clone(),D.textItalic="",m=new a.RTFNode(this.evaluator,e[v].type,"mathSymbol",D),y[y.length-1].addChild(m);else if("+"==e[v].type||"-"==e[v].type||"*"==e[v].type||"="==e[v].type)m=new a.RTFNode(this.evaluator,e[v].type,"mathSymbol",y[y.length-1].style.clone()),y[y.length-1].addChild(m);if(null!=
l){var S=l.getRoot();S.stableWidth=E;S.getTextMetrics();S.hasFormula=G}return S};a.FontStyle=function(a,b,c,d,f,e,g){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=f;this.textOverline=e;this.textColor=g};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font: "+this.fontSize+"px "+this.fontType+"; ";this.textUnderline&&!this.textOverline&&
(a+="text-decoration: underline; ");!this.textUnderline&&this.textOverline&&(a+="text-decoration: overline; ");this.textUnderline&&this.textOverline&&(a+="text-decoration: underline overline; ");this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: bold; ");!this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: bold; ");!this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: normal; ");
this.textColor&&(a+="color: "+this.textColor+"; ");return a+"'"};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,this.fontType,this.textItalic,this.textBold,this.textUnderline,this.textOverline,this.textColor)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b,d,c,h,f,q,m,l,p,n,s,g;a.Space=function(b,c){this.parent=b;j=this.evaluator=this.parent.evaluator;k=j.parser;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;j=this.evaluator;b=this.id;this.displaceRegionNorth=e.displaceRegionNorth||0;this.displaceRegionWest=e.displaceRegionWest||0;h=parseInt(e.container.height);f=parseInt(e.container.width);j.setVariable(b+"._w",this.w);j.setVariable(b+"._h",this.h);this.x=j.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=j.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+
"px",this.container.style.top=this.y+"px");0<=this.y?(d=h-this.y,this.h>d&&(this.h=d)):(d=this.h+this.y,this.h=d>=h?h:d);0<=this.x?(c=f-this.x,this.w>c&&(this.w=c)):(c=this.w+this.x,this.w=c>=f?f:c);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:(q=parseFloat(m),q!=m&&(q=0),this.Ox=q));this.OyExpr&&(l=this.OyExpr,"%"===l[l.length-1]?this.Oy=this.h*parseFloat(l)/
100:(q=parseFloat(l),q!=l&&(q=0),this.Oy=q));2!==e.version?(j.setVariable(b+"._w",this.w),j.setVariable(b+"._h",this.h),j.setVariable(b+".escala",this.scale),j.setVariable(b+".Ox",this.Ox),j.setVariable(b+".Oy",this.Oy),j.setVariable(b+".mouse_x",0),j.setVariable(b+".mouse_y",0),j.setVariable(b+".mouse_pressed",0)):(q=j.getVariable("_w"),void 0===q&&(q=this.w),j.setVariable("_w",q),q=j.getVariable("_h"),void 0===q&&(q=this.h),j.setVariable("_h",q),q=j.getVariable("escala"),void 0===q&&(q=this.scale),
j.setVariable("escala",q),q=j.getVariable("Ox"),void 0===q&&(q=this.Ox),j.setVariable("Ox",q),q=j.getVariable("Oy"),void 0===q&&(q=this.Oy),j.setVariable("Oy",q),j.setVariable("mouse_x",0),j.setVariable("mouse_y",0),j.setVariable("mouse_pressed",0),""===this.x_axis&&""===this.y_axis&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a){a.background&&"R3"!==this.type?
this.backgroundGraphics.push(a):this.graphics.push(a)};a.Space.prototype.getRelativeX=function(a){return(a-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-a+this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};a.Space.prototype.findOffset=function(){p=this.container;this.offsetTop=this.offsetLeft=0;n=this.container.style.display;
for(this.container.style.display="block";p;){s=null;p.getAttribute&&(s=p.getAttribute("class"));if(s&&("DescartesSpace2DContainer"===s||"DescartesSpace3DContainer"===s||"DescartesAppContainer"===s))this.offsetLeft+=p.offsetLeft||0,this.offsetTop+=p.offsetTop||0;p=p.parentNode}this.container.style.display=n};a.Space.prototype.getCursorPosition=function(b){g=a.getCursorPosition(b);return{x:g.x-this.offsetLeft,y:g.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){var e,j;if(a.loadLib)return a;
var k=Math.floor,b=Math.round,d=2*Math.PI,c=a.convertFont("SansSerif,PLAIN,12"),h=a.convertFont("Monospaced,PLAIN,12"),f,q,m,l,p,n,s,g,t,u,r,w,z,B,x,E,C,A,y,G,F,L,J,v,M,D,H,K,I;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.OxString=2!==b.version?f.id+".Ox":"Ox";f.OyString=2!==b.version?f.id+".Oy":"Oy";f.scaleString=2!==
b.version?f.id+".escala":"escala";f.wString=f.id+"._w";f.hString=f.id+"._h";"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;q=
f.evaluator;m=f.parent;q.setVariable(f.wString,f.w);q.setVariable(f.hString,f.h);f.drawIfValue=0<q.evalExpression(f.drawif);if(f.drawIfValue){p=f.x!==q.evalExpression(f.xExpr)+f.displaceRegionWest;n=f.y!==q.evalExpression(f.yExpr)+m.plecaHeight+f.displaceRegionNorth;f.spaceChange=a||p||n||f.drawBefore!==f.drawIfValue||f.Ox!==q.getVariable(f.OxString)||f.Oy!==q.getVariable(f.OyString)||f.scale!==q.getVariable(f.scaleString);f.x=p?q.evalExpression(f.xExpr)+f.displaceRegionWest:f.x;f.y=n?q.evalExpression(f.yExpr)+
m.plecaHeight+f.displaceRegionNorth:f.y;f.Ox=q.getVariable(f.OxString);f.Oy=q.getVariable(f.OyString);f.scale=q.getVariable(f.scaleString);f.drawBefore=f.drawIfValue;1E-6>f.scale?(f.scale=1E-6,q.setVariable(f.scaleString,1E-6)):1E6<f.scale&&(f.scale=1E6,q.setVariable(f.scaleString,1E6));if(p||n)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(){q=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));g=this.scale;t=0;for(u=0>this.w+this.h?0:this.w+this.h;g>u;)g/=10,t++;for(;g<u/10;)g*=10;l.lineWidth=1;""!==this.net&&(l.strokeStyle=this.net.getColor(),this.drawMarks(l,g/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,g,-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,g,4);this.drawMarks(l,g/2,2);this.drawMarks(l,g/10,1)}if(""!==this.x_axis||""!==this.y_axis)l.fillStyle=this.axes.getColor(),
l.font=c,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=c,l.textAlign="start",l.textBaseline="bottom",g>(this.w+this.h)/2?this.drawNumbers(l,g/5,g<=this.scale?t+1:t):g>(this.w+this.h)/4?this.drawNumbers(l,g/2,g<=this.scale?t+1:t):this.drawNumbers(l,g,t));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++)s=this.graphics[a],""!==s.trace&&this.drawTrace&&s.drawTrace(),s.draw();a=0;for(b=this.graphicsCtr.length;a<b;a++)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=h,l.textAlign="center",l.textBaseline="alphabetic",F=1>=this.scale?this.mouse_x.toFixed(0):
this.mouse_x.toFixed(this.scale.toString().length),L=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),J="("+F+","+L+")",v=k(l.measureText(J).width/2),M=this.getAbsoluteX(this.mouse_x),D=this.getAbsoluteY(this.mouse_y),H=k(M),K=k(D-10),H+v>this.w?H=this.w-v:0>H-v&&(H=v),K+1>this.h?K=this.h:0>K-14&&(K=15),l.fillText(J,H,K),l.beginPath(),l.arc(M,D,2.5,0,d,!0),l.stroke())};a.Space2D.prototype.drawMarks=function(a,c,d){r=this.w;w=this.h;C=0;A=r;y=0;G=w;x=k(r/2+this.Ox);
E=k(w/2+this.Oy);0<=d&&(C=x-d,A=x+d,y=E-d,G=E+d);a.beginPath();for(d=-b(x/c);(z=x+b(d*c))<r;d++)a.moveTo(z+0.5,y+0.5),a.lineTo(z+0.5,G+0.5);for(d=-b(E/c);(B=E+b(d*c))<w;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){r=this.w;w=this.h;x=k(r/2+this.Ox);E=k(w/2+this.Oy);for(var d=-b(x/c);(z=x+b(d*c))<r;d++)a.fillText(parseFloat((d*c/this.scale).toFixed(4)),z+1,E-2);for(d=-b(E/c);(B=E+b(d*c))<w;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){l.click=1;l.evaluator.setVariable(l.id+".mouse_pressed",1);l.parent.deactivateGraphiControls();g(a);window.addEventListener("touchmove",m);window.addEventListener("touchend",c);a.preventDefault()}function c(a){l.click=0;l.evaluator.setVariable(l.id+".mouse_pressed",0);window.removeEventListener("touchmove",m,!1);window.removeEventListener("touchend",c,!1);a.preventDefault();l.parent.update()}
function d(b){l.click=1;l.evaluator.setVariable(l.id+".mouse_pressed",1);l.parent.deactivateGraphiControls();l.whichButton=a.whichButton(b);"R"===l.whichButton&&(window.addEventListener("mouseup",f),l.fixed||(l.clickPosForZoom=l.getCursorPosition(b).y,l.tempScale=l.scale,window.addEventListener("mousemove",h)));"L"===l.whichButton&&(l.evaluator.setVariable(l.id+".mouse_pressed",1),g(b),window.addEventListener("mousemove",m),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){l.click=
0;l.evaluator.setVariable(l.id+".mouse_pressed",0);a.preventDefault();"R"===l.whichButton&&window.removeEventListener("mousemove",h,!1);l.sensitive_to_mouse_movements||window.removeEventListener("mousemove",m,!1);window.removeEventListener("mouseup",f,!1);l.parent.update()}function g(a){l.posAnte=l.getCursorPosition(a);l.mouse_x=l.getRelativeX(l.posAnte.x);l.mouse_y=l.getRelativeY(l.posAnte.y);l.evaluator.setVariable(l.id+".mouse_x",l.mouse_x);l.evaluator.setVariable(l.id+".mouse_y",l.mouse_y);l.parent.update()}
function h(a){a.preventDefault();l.clickPosForZoomNew=l.getCursorPosition(a).y;l.evaluator.setVariable(l.scaleString,l.tempScale+l.tempScale/45*((l.clickPosForZoom-l.clickPosForZoomNew)/10));l.parent.update()}function m(a){l.fixed||(l.posNext=l.getCursorPosition(a),e=k(l.posAnte.x-l.posNext.x),j=k(l.posAnte.y-l.posNext.y),l.evaluator.setVariable(l.OxString,l.Ox-e),l.evaluator.setVariable(l.OyString,l.Oy-j),l.posAnte.x-=e,l.posAnte.y-=j);g(a);a.preventDefault()}var l=this;I=a.hasTouchSupport;l.canvas.oncontextmenu=
function(){return!1};I&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",g),this.canvas.addEventListener("touchstart",b));I||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",g),this.canvas.addEventListener("mousedown",d))};return a}(descartesJS||{}),descartesJS=function(a){var e,j,k;function b(a,b){return b.depth-a.depth}function d(b,c){S=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));U=a.add3D(b,a.scalarProduct3D(S,-2));V=a.norm3D(U);
return 0!==V?a.scalarProduct3D(U,1/V):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var c=Math.floor,h=Math.round,f=Math.max,q=Math.cos,m=Math.sin,l=Math.sqrt,p=15*Math.PI/180,n,s,g,t,u,r,w,z,B,x,E,C,A,y,G,F,L,J,v,M,D,H,K,I=[],O,Q,P,R,N,T,S,U,V;a.Space3D=function(b,c){a.Space.call(this,b,c);g=this;g.backgroundCanvas=document.createElement("canvas");g.backgroundCanvas.setAttribute("id",g.id+"_background");g.backgroundCanvas.setAttribute("width",g.w+"px");g.backgroundCanvas.setAttribute("height",g.h+
"px");g.canvas=document.createElement("canvas");g.canvas.setAttribute("id",g.id+"_canvas");g.canvas.setAttribute("width",g.w+"px");g.canvas.setAttribute("height",g.h+"px");g.canvas.setAttribute("class","DescartesSpace3DCanvas");g.canvas.setAttribute("style","z-index: "+g.zIndex+";");g.ctx=g.canvas.getContext("2d");g.ctx.imageSmoothingEnabled=!1;g.ctx.mozImageSmoothingEnabled=!1;g.ctx.webkitImageSmoothingEnabled=!1;g.graphicControlContainer=document.createElement("div");g.graphicControlContainer.setAttribute("id",
g.id+"_graphicControls");g.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.numericalControlContainer=document.createElement("div");g.numericalControlContainer.setAttribute("id",g.id+"_numericalControls");g.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.container=document.createElement("div");g.container.setAttribute("id",g.id);g.container.setAttribute("class","DescartesSpace3DContainer");
g.container.setAttribute("style","left: "+g.x+"px; top: "+g.y+"px; z-index: "+g.zIndex+";");g.container.appendChild(g.backgroundCanvas);g.container.appendChild(g.canvas);g.container.appendChild(g.graphicControlContainer);g.container.appendChild(g.numericalControlContainer);b.container.insertBefore(g.container,b.loader);g.eye={x:0,y:0,z:0};g.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=g.lights.length;d<f;d++)g.lights[d]=a.normalize3D(g.lights[d]);g.light3=
{x:0,y:0,z:0};g.intensity=[0.4,0.5,0.3,0];g.userIntensity=0;g.dim=1;g.tmpIntensity=[];g.OxStr=g.id+".Ox";g.OyStr=g.id+".Oy";g.scaleStr=g.id+".escala";g.wStr=g.id+"._w";g.hStr=g.id+"._h";g.obsStr=g.id+".observador";g.rotZStr=g.id+".rot.z";g.rotYStr=g.id+".rot.y";g.userI_Dim_Str=g.id+".userIlum.dim";g.userI_I_Str=g.id+".userIlum.I";g.userI_x_Str=g.id+".userIlum.x";g.userI_y_Str=g.id+".userIlum.y";g.userI_z_Str=g.id+".userIlum.z";g.evaluator.setVariable(g.rotZStr,0);g.evaluator.setVariable(g.rotYStr,
0);g.evaluator.setVariable(g.userI_Dim_Str,g.dim);g.evaluator.setVariable(g.userI_I_Str,g.userIntensity);g.evaluator.setVariable(g.userI_x_Str,0);g.evaluator.setVariable(g.userI_y_Str,0);g.evaluator.setVariable(g.userI_z_Str,0);g.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(){g=this;g.uber.init.call(g);g.canvas&&(g.canvas.setAttribute("width",g.w+"px"),g.canvas.setAttribute("height",g.h+"px"));g.container&&g.findOffset();g.w_2=g.w/2;g.h_2=g.h/2;g.oldMouse=
{x:0,y:0}};a.Space3D.prototype.update=function(a){g=this;n=g.evaluator;s=g.parent;n.setVariable(g.wStr,g.w);n.setVariable(g.hStr,g.h);g.drawIfValue=0<n.evalExpression(g.drawif);if(g.drawIfValue){B=g.x!==n.evalExpression(g.xExpr)+g.displaceRegionWest;x=g.y!==n.evalExpression(g.yExpr)+s.plecaHeight+g.displaceRegionNorth;g.spaceChange=a||B||x||g.drawBefore!==g.drawIfValue||g.Ox!==n.getVariable(g.OxStr)||g.Oy!==n.getVariable(g.OyStr)||g.scale!==n.getVariable(g.scaleStr);g.x=B?n.evalExpression(g.xExpr)+
g.displaceRegionWest:g.x;g.y=x?n.evalExpression(g.yExpr)+s.plecaHeight+g.displaceRegionNorth:g.y;g.Ox=n.getVariable(g.OxStr);g.Oy=n.getVariable(g.OyStr);g.scale=n.getVariable(g.scaleStr);g.drawBefore=g.drawIfValue;if(a){var b;a=0;for(var c=g.parent.controls.length;a<c;a++)g.parent.controls[a].id===g.obsStr&&(b=!0);g.observer=b?n.getVariable(g.obsStr)||0.5*(g.w+g.h):2.5*(g.w+g.h);g.observer=f(g.observer,0.1*(g.w+g.h));n.setVariable(g.obsStr,g.observer);g.eye={x:g.observer/g.scale*q(p),y:0,z:g.observer/
g.scale*m(p)};g.D=g.scale*g.eye.x/q(p);g.XE=h(g.scale*g.eye.y+0.5);g.YE=h(g.scale*g.eye.z+0.5)}g.observer=f(n.getVariable(g.obsStr),0.1*(g.w+g.h));n.setVariable(g.obsStr,g.observer);1E-6>g.scale?(g.scale=1E-6,n.setVariable(g.scaleStr,1E-6)):1E6<g.scale&&(g.scale=1E6,n.setVariable(g.scaleStr,1E6));if(B||x)g.container.style.left=g.x+"px",g.container.style.top=g.y+"px",g.findOffset();g.container.style.display="block";g.dim=n.getVariable(g.userI_Dim_Str);g.userIntensity=n.getVariable(g.userI_I_Str);g.light3=
{x:parseInt(n.getVariable(g.userI_x_Str)),y:parseInt(n.getVariable(g.userI_y_Str)),z:parseInt(n.getVariable(g.userI_z_Str))};g.updateCamera();g.draw()}else g.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++)t=this.graphics[a],t.update();this.primitives=[];a=0;for(c=this.graphics.length;a<c;a++){t=this.graphics[a];if(t.split||
this.split)for(var d=a+1;d<c;d++)u=this.graphics[d],(u.split||this.split)&&t.splitFace(u);this.primitives=this.primitives.concat(t.primitives||[])}r=this.primitives;w=r.length;for(a=0;a<w;a++)r[a].computeDepth(this);r=r.sort(b);for(a=0;a<w;a++)r[a].draw(this.ctx,this);a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.updateCamera=function(){g=this;g.D=g.observer;g.eye.x=g.D/g.scale;g.eye.y=g.XE/g.scale;g.eye.z=g.YE/g.scale};a.Space3D.prototype.rotateVertex=
function(b){L=a.degToRad(g.evaluator.getVariable(g.rotZStr));J=q(L);v=m(L);e=b.x*J-b.y*v;j=b.x*v+b.y*J;k=b.z;L=a.degToRad(g.evaluator.getVariable(g.rotYStr));J=q(L);v=m(L);return{x:k*v+e*J,y:j,z:k*J-e*v}};a.Space3D.prototype.project=function(a){g=this;A=g.eye.x-a.x;y=g.eye.y-a.y;G=g.eye.z-a.z;F=-a.x/l(A*A+y*y+G*G)||0;A=g.scale*(a.y+F*(g.eye.y-a.y));y=-g.scale*(a.z+F*(g.eye.z-a.z));return{x:parseInt(A+this.w_2+this.Ox),y:parseInt(y+this.h_2+this.Oy),z:F}};a.Space3D.prototype.computeColor=function(b,
f,e){R=a.subtract3D(this.eye,f.average);N=a.norm3D(R);T=a.scalarProduct3D(R,1/N);this.lights[3]=a.subtract3D(this.light3,f.average);K=a.norm3D(this.lights[3]);for(var g=0,h=this.intensity.length-1;g<h;g++)I[g]=this.intensity[g]*this.dim;I[3]=this.userIntensity*this.userIntensity/K||0;O=e?this.dim/2:this.dim/4;Q=0;P=0<=f.direction?f.normal:a.scalarProduct3D(f.normal,-1);g=0;for(h=this.lights.length;g<h;g++)e?(Q=Math.max(0,a.dotProduct3D(d(this.lights[g],P),T)),Q*=Q*Q):Q=Math.max(0,a.dotProduct3D(this.lights[g],
P)),O+=I[g]*Q;O=Math.min(O,1);M=c(b.r*O);D=c(b.g*O);H=c(b.b*O);return"rgba("+M+","+D+","+H+","+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",j);window.addEventListener("touchend",c);a.preventDefault()}function c(a){g.click=
0;g.evaluator.setVariable(g.id+".mouse_pressed",0);window.removeEventListener("touchmove",j,!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",j),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",j,!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 j(b){if(!g.fixed&&g.click){E=parseInt(50*(g.oldMouse.x-g.mouse_x));C=parseInt(50*(g.oldMouse.y-g.mouse_y));
if(E!==g.disp.x||C!==g.disp.y)g.alpha=a.degToRad(g.evaluator.getVariable(g.rotZStr)),g.beta=a.degToRad(-g.evaluator.getVariable(g.rotYStr)),g.alpha=h(a.radToDeg(g.alpha)-E),g.beta=h(a.radToDeg(g.beta)-C),g.evaluator.setVariable(g.rotZStr,g.alpha),g.evaluator.setVariable(g.rotYStr,-g.beta),g.disp.x=E,g.disp.y=C,g.oldMouse.x=g.getRelativeX(g.posAnte.x),g.oldMouse.y=g.getRelativeY(g.posAnte.y);e(b);b.preventDefault()}}g=this;z=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};z&&this.canvas.addEventListener("touchstart",
b);z||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(j,k){a.Space.call(this,j,k);this.exportarVars=this.importarVars=null;e=j.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,d=0,c=e.length;d<c&&!(e[d].match("<applet")&&(b=!0),b&&(k+=e[d]),e[d].match("</applet"));d++);d=document.createElement("div");d.innerHTML=k;d.firstChild.setAttribute("width",
this.w);d.firstChild.setAttribute("height",this.h);k=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(d.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");k?this.parent.container.replaceChild(this.descApp.container,
k):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);k=this.descApp.spaces;d=0;for(c=k.length;d<c;d++)k[d].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var h=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();h.exportar()}}else k=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),
this.descApp.container.setAttribute("class","DescartesAppContainer"),d="position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";",this.image&&("topleft"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":
"patch"==this.bg_display?d+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",d),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 d in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(d)&&d.match(/^public./)&&this.importarVars.push({varName:d,value:this.evaluator.getVariable(d)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,e=!1,b=0,d=this.importarVars.length;b<
d;b++)a=this.evaluator.getVariable(this.importarVars[b].varName),a!=this.importarVars[b].value&&(this.importarVars[b].value=a,this.descApp.evaluator.setVariable(this.importarVars[b].varName,this.importarVars[b].value),e=!0);e&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,j,k,b;a.SpaceHTML_IFrame=function(b,c){a.Space.call(this,b,c);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);j=this.x!==e.evalExpression(this.xExpr)+this.displaceRegionWest;k=this.y!==e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=j?e.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=
k?e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(j||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 d=a.loader.height,
k=document.createElement("canvas");k.width=b;k.height=d;var j=k.getContext("2d");j.save();j.strokeStyle="#1f375d";j.fillStyle="#1f375d";j.lineCap="round";j.lineWidth=2;j.beginPath();e=b<d?b/360:d/195;e=2.5<e?2.5:e;j.translate((b-120*e)/2,(d-65*e)/2);j.scale(e,e);j.moveTo(3,25);j.lineTo(3,1);j.lineTo(21,1);j.bezierCurveTo(33,1,41,15,41,25);j.stroke();j.beginPath();j.moveTo(1,63);j.lineTo(1,64);j.moveTo(5,62);j.lineTo(5,64);j.moveTo(9,61);j.lineTo(9,64);j.moveTo(13,60);j.lineTo(13,64);j.moveTo(17,58);
j.lineTo(17,64);j.moveTo(21,56);j.lineTo(21,64);j.moveTo(25,53);j.lineTo(25,64);j.moveTo(29,50);j.lineTo(29,64);j.moveTo(33,46);j.lineTo(33,64);j.moveTo(37,41);j.lineTo(37,64);j.moveTo(41,32);j.lineTo(41,64);j.stroke();j.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";j.fillText("escartes",45,33);j.fillText("JS",98,64);j.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,d=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,j=/vector|array|bektore|vecteur|matriz/g,p=/archivo|file|fitxer|artxibo|fichier|arquivo/g;
this.arquimedes&&(d["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),d["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1}),d["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var n,s,g,t,u,r;t=0;for(u=b.length;t<u;t++){if(n=b[t].value.match(e)){g=0;for(r=n.length;g<r;g++)s=n[g],!s.toLowerCase().match(/vacio.gif$/)&&""!=s.substring(0,s.length-4)&&(d[s]=new Image,d[s].addEventListener("load",function(){this.ready=1}),d[s].addEventListener("error",
function(){this.errorload=1}),d[s].src=s)}if(n=b[t].value.match(k)){g=0;for(s=n.length;g<s;g++)this.initAudio(n[g])}(g=b[t].value.match(j)&&b[t].value.match(p))&&this.lessonParser.parseAuxiliar(b[t].value)}for(var w in d)d.hasOwnProperty(w)&&this.images.length++;for(w in f)f.hasOwnProperty(w)&&this.audios.length++;var z=this,B=this.images.length+this.audios.length,x=function(){z.readys=0;for(var a in d)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&z.readys++;for(a in z.audios)f.hasOwnProperty(a)&&
(f[a].ready||f[a].errorload)&&z.readys++;z.readys!=B?setTimeout(x,30):(clearTimeout(z.timer),z.descartesApp.initBuildApp())};x()};a.DescartesLoader.prototype.initAudio=function(b){var d=this.audios;d[b]=new Audio(b);d[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)?(d[b]=new Audio(this.filename.replace("mp3","ogg")),d[b].filename=this.filename.replace("mp3",
"ogg"),d[b].addEventListener("canplaythrough",f),d[b].addEventListener("load",f),d[b].addEventListener("error",e),d[b].load()):(console.log("El archivo '"+b+"' no puede ser reproducido"),this.errorload=1)};d[b].addEventListener("canplaythrough",f);d[b].addEventListener("load",f);d[b].addEventListener("error",e);a.hasTouchSupport?(d[b].load(),d[b].play(),d[b].ready=1):d[b].load()};var j,k,b,d;a.DescartesLoader.prototype.drawLoaderBar=function(a,h,f){j=this.barWidth;k=this.barHeight;b=this.images.length+
this.audios.length;d=2*(j-2)/b;a.translate(h/2,(f-65*e)/2+90*e);a.scale(e,e);a.strokeRect(-j,-k,2*j,k);a.fillStyle="gray";a.fillRect(-j+2,-k+2,2*(j-2),k-4);a.fillStyle="#1f375d";a.fillRect(-j+2,-k+2,this.readys*d,k-4);a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var b="[",d=0,c=a.length;d<c;d++){if(a[d]instanceof Array)b+=e(a[d]);else{j=a[d];if("undefined"==typeof j||!j)j=0;"string"==typeof j&&(j="'"+j+"'");b+=j}d<c-1&&(b+=",")}return b+"]"}if(a.loadLib)return a;
a.DescartesApp=function(e){this.applet=e;this.parentContainer=e.parentNode;this.width=parseFloat(e.getAttribute("width"));this.height=parseFloat(e.getAttribute("height"));this.decimal_symbol=".";this.children=e.getElementsByTagName("param");this.code=e.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=-1;this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.firstRun=!0;this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class",
"i")||!!this.code.match("Arquimedes","i")||!!this.code.match("Discurso","i");this.licenseA="{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto del  {\\*\\hyperlink Ministerio de Educaci\u00f3n de Espa\u00f1a|http://recursostic.educacion.es/descartes/web/DescartesWeb2.0/} y\\par                                        el {\\*\\hyperlink Instituto de Matem\u00e1ticas|http://arquimedes.matem.unam.mx/} de la Universidad Nacional Aut\u00f3noma de M\u00e9xico, cedido bajo licencia {\\*\\hyperlink EUPL v 1.1|/resources/eupl_v1.1es.pdf}, con {\\*\\hyperlink c\u00f3digo en Java|http://recursostic.educacion.es/descartes/web/source/}.}";
e=this.children;for(var b,d=0,c=0,h=0,f=e.length;h<f;h++)b=e[h],"rtf_height"==b.name&&(d=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),c=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&d&&(this.height=d+c+70);this.init()};a.DescartesApp.prototype.init=function(){this.spaces=[];this.externalSpace={container:document.createElement("div"),controls:[]};this.northSpace={container:document.createElement("div"),
controls:[]};this.southSpace={container:document.createElement("div"),controls:[]};this.eastSpace={container:document.createElement("div"),controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.specialSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};this.controls=[];this.auxiliaries=[];this.events=[];this.cacheVars={};this.getVarsNames={};this.numberOfIframes=this.plecaHeight=this.tabindex=
this.zIndex=0;void 0!=this.container&&this.parentContainer.removeChild(this.container);this.container=document.createElement("div");this.loader=document.createElement("div");this.parentContainer.appendChild(this.container);this.container.width=this.width;this.container.height=this.height;this.container.setAttribute("class","DescartesAppContainer");this.container.setAttribute("style","width:"+this.width+"px; height:"+this.height+"px;");this.container.appendChild(this.loader);this.loader.width=this.width;
this.loader.height=this.height;this.loader.setAttribute("class","DescartesLoader");this.loader.setAttribute("style","width:"+this.width+"px; height:"+this.height+"px; z-index:1000;");this.firstRun?this.descartesLoader=new a.DescartesLoader(this):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){for(var a=this.children,b=this.lessonParser,d=[],c=[],e=[],f=[],j=[],m=[],l,p=0,n=a.length;p<n;p++)if(l=a[p],"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;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 s=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='[10,"+(s-25)+"]' background='yes' text='"+this.licenseA+"'");f.push("space='descartesJS_scenario' type='image' expresion='[15,"+s+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==l.name.charAt(0)?(l.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,d.push(l.value)):"C"==l.name.charAt(0)&&"_"==l.name.charAt(1)?c.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)?j.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));p=0;for(n=d.length;p<n;p++)a=b.parseSpace(d[p]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;p=0;for(n=f.length;p<n;p++)if(d=b.parseGraphic(f[p]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);p=0;for(n=
j.length;p<n;p++)(d=b.parse3DGraphic(j[p]))&&d.space.addGraph(d);p=0;for(n=c.length;p<n;p++)this.controls.push(b.parseControl(c[p]));p=0;for(n=e.length;p<n;p++)b.parseAuxiliar(e[p]);p=0;for(n=m.length;p<n;p++)this.animation=b.parseAnimation(m[p]);this.configRegions();this.updateAuxiliaries();p=0;for(n=this.controls.length;p<n;p++)this.controls[p].init();this.updateControls();this.updateSpaces(!0);var g=this;this.numberOfIframes?setTimeout(function(){g.finishInit()},300*this.numberOfIframes):this.finishInit()};
a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";window.parent!==window&&(this.parentContainer.style.margin="0px",this.parentContainer.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready"},"*"),a.onResize());a.externalEvaluator=new a.Evaluator};a.DescartesApp.prototype.configRegions=function(){var e=this.evaluator.parser,b=this.buttonsConfig,
d=this.container;if(2!=this.version)var c="15",h=100,f=100,j=100,m=100;else c="14",h=63,f=50,j=44,m=53;var l=0,p=0,n=0,s=n=0,g=0,t=0,u=0,r=0,t=this.northSpace.controls,w=this.southSpace.controls,z=this.eastSpace.controls,B=this.westSpace.controls;if(0<b.rowsNorth||0<t.length||b.about||b.config){0>=b.rowsNorth?(l=b.height,b.rowsNorth=1):l=b.height*b.rowsNorth;var x=this.northSpace.container;x.setAttribute("id","descartesJS_northRegion");x.setAttribute("style","width:"+d.width+"px; height:"+l+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");
d.insertBefore(x,this.loader);var g=d.width,E=0;b.about&&(E=h,g-=E);b.config&&(g-=f);for(var x=Math.ceil(t.length/b.rowsNorth),C=g/x,n=0,A=t.length;n<A;n++)t[n].expresion=e.parse("("+(E+C*(n%x))+","+b.height*Math.floor(n/x)+","+C+","+b.height+")"),t[n].drawif=e.parse("1"),t[n].init();if(b.about){var y;"espa\u00f1ol"==this.language?y="cr\u00e9ditos":"english"==this.language&&(y="about");(new a.Button(this,{region:"north",name:y,font_size:e.parse(c),expresion:e.parse("(0, 0, "+h+", "+l+")")})).update()}b.config&&
(y="config",(new a.Button(this,{region:"north",name:y,font_size:e.parse(c),action:"config",expresion:e.parse("("+(g+h)+", 0, "+f+", "+l+")")})).update())}if(0<b.rowsSouth||0<w.length||b.init||b.clear){0>=b.rowsSouth?(p=b.height,b.rowsSouth=1):p=b.height*b.rowsSouth;t=d.width;E=0;b.init&&(E=j,t-=E);b.clear&&(t-=m);x=this.southSpace.container;x.setAttribute("id","descartesJS_southRegion");x.setAttribute("style","width:"+d.width+"px; height:"+p+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+
(d.height-p)+"px; z-index:100;");d.insertBefore(x,this.loader);x=Math.ceil(w.length/b.rowsSouth);C=t/x;n=0;for(A=w.length;n<A;n++)w[n].expresion=e.parse("("+(E+C*(n%x))+","+b.height*Math.floor(n/x)+","+C+","+b.height+")"),w[n].drawif=e.parse("1"),w[n].init();b.init&&("espa\u00f1ol"==this.language?y="inicio":"english"==this.language&&(y="init"),(new a.Button(this,{region:"south",name:y,font_size:e.parse(c),action:"init",expresion:e.parse("(0, 0, "+j+", "+p+")")})).update());b.clear&&("espa\u00f1ol"==
this.language?y="limpiar":"english"==this.language&&(y="clear"),(new a.Button(this,{region:"south",name:y,font_size:e.parse(c),action:"clear",expresion:e.parse("("+(t+j)+", 0, "+m+", "+p+")")})).update())}if(0<z.length){n=d.height-l-p;u=b.widthEast;x=this.eastSpace.container;x.setAttribute("id","descartesJS_eastRegion");x.setAttribute("style","width:"+u+"px; height:"+n+"px; background:#c0c0c0; position:absolute; left:"+(d.width-u)+"px; top:"+l+"px; z-index:100;");d.insertBefore(x,this.loader);n=0;
for(A=z.length;n<A;n++)z[n].expresion=e.parse("(0,"+b.height*n+","+u+","+b.height+")"),z[n].drawif=e.parse("1"),z[n].init()}if(0<B.length){n=d.height-l-p;r=b.widthWest;x=this.westSpace.container;x.setAttribute("id","descartesJS_westRegion");x.setAttribute("style","width: "+r+"px; height: "+n+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+l+"px; z-index: 100;");d.insertBefore(x,this.loader);n=0;for(A=B.length;n<A;n++)B[n].expresion=e.parse("(0,"+b.height*n+","+r+","+b.height+")"),
B[n].drawif=e.parse("1"),B[n].init()}if(this.editableRegionVisible){s=b.height;x=this.editableRegion.container;x.setAttribute("id","descartesJS_editableRegion");x.setAttribute("style","width:"+d.width+"px; height:"+s+"px; position:absolute; left:0px; top:"+(d.height-p-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");d.insertBefore(x,this.loader);e=this.editableRegion.textFields;b=d.width/e.length;c=a.getFieldFontSize(s);n=0;for(A=e.length;n<A;n++)"div"==e[n].type?(x.appendChild(e[n].container),
e[n].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+s+"px; position: absolute; left: "+n*b+"px; top: 0px;"),h=e[n].container.firstChild,h.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+c+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+s+"px; text-align: center; line-height: "+s+"px;"),f=h.offsetWidth,h.style.width=f+"px",h.firstChild.textContent=
h.firstChild.textContent.substring(3,h.firstChild.textContent.length-3),e[n].container.lastChild.setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+c+"px; width:"+(b-f)+"px; height:"+s+"px; position:absolute; left:"+f+"px; top:0px; border:2px groove white;")):(x.appendChild(e[n]),e[n].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+c+"px; width:"+b+"px; height:"+s+"px; position:absolute; left:"+
n*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=l;this.displaceRegionWest=r;d.width-=u;d.height=d.height-p-s;n=0;for(A=this.spaces.length;n<A;n++)this.spaces[n].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,d=this.controls.length;b<d;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=
function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,d=this.spaces.length;b<d;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<
b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=
0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;if(a)return b[a]||(b[a]=new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;if(a){if(!b[a]){var d=file.lastIndexOf("."),d=-1===d?file.lenght:d;file.substring(0,d);b[a]=new Audio(a);var c=function(){this.ready=1};b[a].addEventListener("canplaythrough",c);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",c),b[a].addEventListener("load",c),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,d=0,c=this.controls.length;d<
c;d++)if(b=this.controls[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,d=0,c=this.controls.length;d<c;d++)if(b=this.controls[d],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,d=0,c=this.spaces.length;d<c;d++)if(b=this.spaces[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,d=0,c=this.spaces.length;d<c;d++)if(b=
this.spaces[d],b.id==a)return b;return{update:function(){},w:0}};var j;a.DescartesApp.prototype.getState=function(){var a,b="",d=this.evaluator.variables,c;for(c in d)d.hasOwnProperty(c)&&(a=d[c],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=c&&"pi"!=c&&"e"!=c&&"Infinity"!=c&&"-Infinity"!=c&&"object"!=typeof a)&&(b=""!=b?b+"\n"+c+"="+a:c+"="+a));var d=this.evaluator.vectors,h;for(h in d)d.hasOwnProperty(h)&&(a=d[h],b=b+"\n"+h+"="+e(a));h=this.evaluator.matrices;for(var f in h)h.hasOwnProperty(f)&&
(a=h[f],b=b+"\n"+f+"="+e(a));return b};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var b,d,c=0,e=a.length;c<e;c++)b=a[c].split("="),2<=b.length&&(d=eval(b[1]),-1!=b[1].indexOf("[[")?(this.evaluator.matrices[b[0]]=d,this.evaluator.matrices[b[0]].rows=d.length,this.evaluator.matrices[b[0]].cols=d[0].length):-1!=b[1].indexOf("[")?(this.evaluator.vectors[b[0]]=d,this.evaluator.variables[b[0]+".long"]=d.length):this.evaluator.variables[b[0]]=d),this.update()};a.DescartesApp.prototype.getEvaluation=
function(){for(var a=0,b=0,d="",c=0,e=this.controls.length;c<e;c++)"textfield"==this.controls[c].gui&&this.controls[c].evaluate&&(a++,b+=this.controls[c].ok,this.controls[c].value=""==this.controls[c].value?"''":this.controls[c].value,d+=" \\n "+this.controls[c].id+"="+this.controls[c].value+"|"+this.controls[c].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+d};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,d=a.length;b<d;b++)"textfield"==a[b].gui&&a[b].evaluate&&
a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function e(){a.getFeatures();if(a.hasCanvasSupport){for(var e=document.getElementsByTagName("*"),b=[],d=0,c=e.length;d<c;d++)"DescartesAppContainer"==e[d].className&&b.push(e[d]);d=0;for(c=b.length;d<c;d++)b[d].parentNode.removeChild(b[d]);
for(var b=document.getElementsByTagName("applet"),d=document.getElementsByTagName("ajs"),e=[],h=0,f=b.length;h<f;h++)c=b[h],(c.getAttribute("code").match("DescartesJS")||c.getAttribute("code").match("descinst.DescartesWeb2_0.class")||c.getAttribute("code").match("Descartes")||c.getAttribute("code").match("Arquimedes")||c.getAttribute("code").match("Discurso"))&&e.push(c);h=0;for(f=d.length;h<f;h++)c=d[h],(c.getAttribute("code").match("DescartesJS")||c.getAttribute("code").match("descinst.DescartesWeb2_0.class")||
c.getAttribute("code").match("Descartes")||c.getAttribute("code").match("Arquimedes")||c.getAttribute("code").match("Discurso"))&&e.push(c);b=0;for(d=e.length;b<d;b++)a.apps.push(new a.DescartesApp(e[b])),e[b].className="DescartesJS";document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:none;}";window.addEventListener("resize",a.onResize);window.scrollTo(0,2)}else document.getElementById("StyleDescartesApps").innerHTML="applet {display:block;}"}if(a.loadLib)return a;
a.apps=[];a.getDescartesApps=function(){return a.apps};if(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS){var j=document.getElementById("StyleDescartesApps");j&&j.parentNode.removeChild(j);j=document.createElement("style");j.id="StyleDescartesApps";j.type="text/css";j.setAttribute("rel","stylesheet");j.innerHTML="applet.DescartesJS {display:none;} applet {display:none;}";document.head.appendChild(j)}a.onResize=function(){for(var e,b=0,d=a.apps.length;b<d;b++){e=a.apps[b].spaces;for(var c=
0,h=e.length;c<h;c++)e[c].findOffset()}};a.receiveMessage=function(e){if(0<a.apps.length&&(e=e.data))if("set"===e.type)a.apps[0].evaluator.setVariable(e.name,e.value);else if("update"===e.type)a.apps[0].update();else if("exec"===e.type){var b=a.apps[0].evaluator.getFunction(e.name),d=[];""!==e.value&&(d=e.value.toString().split(","));b&&b.apply(a.apps[0].evaluator,d)}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",e),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||
{});
