/*
 Joel Espinosa Longi
 jlongi@im.unam.mx
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2019-02-12
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.checkStringArgs=function(a,h,k){if(null==a)throw new TypeError("The 'this' value for String.prototype."+k+" must not be null or undefined");if(h instanceof RegExp)throw new TypeError("First argument to String.prototype."+k+" must not be a regular expression");return a+""};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,h,k){a!=Array.prototype&&a!=Object.prototype&&(a[h]=k.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,h,k,f){if(h){k=$jscomp.global;a=a.split(".");for(f=0;f<a.length-1;f++){var n=a[f];n in k||(k[n]={});k=k[n]}a=a[a.length-1];f=k[a];h=h(f);h!=f&&null!=h&&$jscomp.defineProperty(k,a,{configurable:!0,writable:!0,value:h})}};
$jscomp.polyfill("String.prototype.repeat",function(a){return a?a:function(a){var h=$jscomp.checkStringArgs(this,null,"repeat");if(0>a||1342177279<a)throw new RangeError("Invalid count value");a|=0;for(var f="";a;)if(a&1&&(f+=h),a>>>=1)h+=h;return f}},"es6","es3");$jscomp.findInternal=function(a,h,k){a instanceof String&&(a=String(a));for(var f=a.length,n=0;n<f;n++){var e=a[n];if(h.call(k,e,n,a))return{i:n,v:e}}return{i:-1,v:void 0}};
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,k){return $jscomp.findInternal(this,a,k).v}},"es6","es3");$jscomp.polyfill("Array.prototype.fill",function(a){return a?a:function(a,k,f){var h=this.length||0;0>k&&(k=Math.max(0,h+k));if(null==f||f>h)f=h;f=Number(f);0>f&&(f=Math.max(0,h+f));for(k=Number(k||0);k<f;k++)this[k]=a;return this}},"es6","es3");
var babel=function(a){if(a.loadLib)return a;a.loadLib=!0;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto=a["#000000"]="#000000";a.maxenta=a.magenta=a["#ff00ff"]="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu=a["#0000ff"]="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise=a["#00ffff"]=
"#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert=a["#00ff00"]="#00ff00";a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo=a["#ffff00"]="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa=a["#ffc800"]="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho=a["#ff0000"]="#ff0000";a.pink=a.rosa=a.arrosa=a.rose=a["#ffafaf"]="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro=a["#404040"]="#404040";a.gris=a.gray=a.grisa=a.cinza=
a["#808080"]="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro=a["#c0c0c0"]="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=a["#ffffff"]="#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=
a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]="sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=
a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=a.konfig=a["configura\u00e7\u00e3o"]="config";a.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+"]=a.fillP="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=a["preencher-"]=a.fillM="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=
a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=
a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=
a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]=a.version="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=a.language="language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=
a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer=a.doExpr="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto=a.whileExpr="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=
a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]=a.drawif="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]=a.x_axis=
"x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=a["eixo-y"]=a.y_axis="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]=a.exponentialif="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro=
"center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]=a.onlyOnce="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]=a.colorInt="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=
a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto="auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada=a.width="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";
a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=
a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]=
"octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor=a.colour=a.kolorea="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=
a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]=
a.raytrace="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo=a.image="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.zentratu=
a["centr\u00e9e"]=a.centrado="imgcenter";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.tipo_de_macro=a.macro_type=a.tipus_de_macro=a.makro_mota=a.type_de_macro=a.tipo_de_macro=a.tipo_de_macro=a.tipus_de_macro="macro_type";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=a.filas_norte=a.linhas_norte=a.files_nord=a.rowsNorth="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud=a.rowsSouth="rowsSouth";a.ancho_este=
a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est=a.widthEast="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest=a.widthWest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]=a.initAnimation="initAnimation";a["Explicaci\u00f3n"]=
a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";
a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]=a.openURL="openURL";a["abrir Escena"]=
a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]=a.openScene="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=
a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";
a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra=a.x="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=
a.erreproduzitu=a.reproduire=a.reproduzir=a.playAudio="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]=a.activeif="activeif";a.rotfin=a.finrot=a.bukrot=a.endrot="endrot";a.posfin=a.finpos=a.bukpos=a.endpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=
a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]=a.font_size="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=
a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte=a.onlyText="onlyText";a.respuesta=a.answer="answer";a.peso=a.weight=a.pes="weight";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.library="library";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text=a.border="border";a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]=
"audio";a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.anchor="anchor";a.a_left="left";a.a_center="center";a.a_right="right";a.a_justify="justify";a.a_top_left="top_left";a.a_top_center="top_center";a.a_top_right="top_right";a.a_center_left="center_left";a.a_center_center="center_center";a.a_center_right="center_right";a.a_bottom_left="bottom_left";a.a_bottom_center=
"bottom_center";a.a_bottom_right="bottom_right";a.malla=a.mesh="mesh";a.local=a.Local="local";a.rectangle=a["rect\u00e1ngulo"]="rectangle";a.lineDash="lineDash";a.solid="solid";a.dot="dot";a.dash="dash";a.dash_dot="dash_dot";a.offset_dist="offset_dist";a.offset_angle="offset_angle";a.cssClass="cssClass";a.doc="doc";a.flat="flat";a.borderColor="borderColor";a.text_align="text_align";a.image_align="image_align";a.checkbox="checkbox";a.torus=a.toro="torus";a.R="R";a.r="r";a.border_radius="border_radius";
a.radio_group="radio_group";a.font_family="font_family";a.resizable="resizable";a.antialias="antialias";a.image_loader="image_loader";a.expand="expand";a.cover=a.cubrir="expand";a.fit=a.escalar="fit";a.code="code";a.jsfun="jsfun";return a}(babel||{}),descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n={bold:"Bold",italic:"Italic",italics:"Italic","bold+italic":"Italic Bold"};a.serif_font="descartesJS_serif,DJS_symbola,DJS_extra,DJS_serif,Times,'Times New Roman','Liberation Serif','Nimbus Roman No9 L Regular',serif";
a.sansserif_font="descartesJS_sansserif,DJS_symbola,DJS_sansserif,Helvetica,Arial,'Liberation Sans','Nimbus Sans L',sans-serif";a.monospace_font="descartesJS_monospace,DJS_symbola,DJS_monospace,'Courier New',Courier,'Liberation Mono','Nimbus Mono L',monospace";a.convertFont=function(f){if(""==f)return"";h=f.split(",");k="";k+=a.getFontStyle(h[1]);k+=h[2]+"px ";return k+=a.getFontName(h[0].split(" ")[0])};a.getFontName=function(e){e=e.toLowerCase();f=a.monospace_font;if("serif"===e||"times new roman"===
e||"timesroman"===e||"times"===e)f=a.serif_font;else if("sansserif"===e||"arial"===e||"helvetica"===e)f=a.sansserif_font;return f};a.getFontStyle=function(a){return n[a.toLowerCase()]};a.getTextWidth=function(f,d){a.ctx.font=d;return Math.round(a.ctx.measureText(f).width)};a.getFieldFontSize=function(a){a=Math.min(50,a);return a=24<=a?Math.floor(a/2+2-a/16):20<=a?12:17<=a?11:15<=a?10:9};var e;a.getFontMetrics=function(a){var d={};e=parseInt(a.match(/(\d+\.*)+px/)[0]);a.match("sansserif")?(d.ascent=
-3.140767846E-4*(e^2)+.921017849*e+.7767317469,d.descent=-5.851175551E-4*(e^2)+.2674451709*e+1.0887015962,d.h=d.ascent+d.descent,d.baseline=d.ascent):a.match("serif")?(d.ascent=-3.647238191E-5*(e^2)+.8914890964*e+.668615541,d.descent=-9.807742367E-4*(e^2)+.3184618868*e+.8663797537,d.h=d.ascent+d.descent,d.baseline=d.ascent):a.match("monospace")&&(d.ascent=1.192160435E-4*(e^2)+.7541188887*e+1.4106492466,d.descent=-.001256260588*(e^2)+.3926891751*e+.57969422598,d.h=d.ascent+d.descent,d.baseline=d.ascent);
return d};return a}(descartesJS||{});
descartesJS=function(a){function h(){var a,b,c,l,g,d,f;Number.prototype.oToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(e){e=e||0;e=0>e?0:parseInt(e);a=this.toString();-1!==a.indexOf("e")&&(l=a.split("e"),d="-"===l[0][0]?"-":"",g="-"===d?parseFloat(l[0].substring(1)).oToFixed(11):parseFloat(l[0]).oToFixed(11),f=parseInt(l[1]),b=g.indexOf("."),g=g.replace(".",""),0>b+f?(b=0>b?1:b,a=d+"0."+"0".repeat(Math.abs(b+f))+g):a=d+g+"0".repeat(f-g.length+1));b=a.indexOf(".");-1===b?0<e&&
(a+="."+"0".repeat(e)):(c=a.length-b-1,a=c>=e?11>=e?parseFloat(a).oToFixed(e):a.substring(0,b+e+1):a+"0".repeat(e-c));return a}}if(a.loadLib)return a;var k=2*Math.PI,f=360/k,n=k/360,e=Math.floor,m,d,c,r,g,b;a.rangeOK=1;a.cssScale=1;a.extend=function(a,b){if("function"==typeof Object.create)a.prototype=Object.create(b.prototype);else if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var 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*f};a.degToRad=function(a){return a*n};a.drawLine=function(a,c,l,g,d,f,h){a.lineWidth=h||1;a.strokeStyle=f||"black";b=a.lineWidth%2?.5:0;a.beginPath();a.moveTo(e(c)+b,e(l)+b);a.lineTo(e(g)+b,e(d)+b);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;m=a.eval(b);return"rgba("+e(255*m[0][0])+","+e(255*m[0][1])+","+e(255*m[0][2])+","+(1-m[0][3])+")"};a.getFeatures=function(){var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&
window.hasOwnProperty("ontouchstart")||"ontouchstart"in window||/android/i.test(b);a.isIOS=/iPad|iPhone/i.test(navigator.userAgent);a.isMsEdge=/Edge/i.test(navigator.userAgent);b=document.createElement("canvas");a.hasCanvas=b.getContext&&b.getContext("2d");a.hasCanvas&&(a.ctx=a.hasCanvas,a._ratio=1.6);h()};var l,w;a.removeNeedlessDecimals=function(a){if("string"==typeof a&&(l=a.indexOf("."),-1!==l)){w=a.substring(l);if(0==parseFloat(w))return a.substring(0,l);for(var b=w.length;0<b;b--)if(0!==w.charAt(b))return a.substring(0,
l+b+1)}return a};a.returnValue=function(a){return"number"===typeof a?parseFloat(a.toFixed(11)):a};a.whichBtn=function(a){return 2>a.which?"L":2===a.which?"M":"R"};a.getCursorPosition=function(b,l){b.touches?(d=b.touches[0],c=d.pageX,r=d.pageY):(c=b.pageX,r=b.pageY);g=l.getBoundingClientRect();return{x:(c-window.pageXOffset-g.left)/a.cssScale,y:(r-window.pageYOffset-g.top)/a.cssScale}};window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||
window.msRequestAnimationFrame;window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame;a.setInterval=function(a,b){function c(){(new Date).getTime()-l>=b&&(a.call(),l=(new Date).getTime());g.value=requestAnimationFrame(c)}if(!requestAnimationFrame)return setInterval(a,b);var l=(new Date).getTime(),g={};g.value=requestAnimationFrame(c);return g};a.clearInterval=function(a){a&&(cancelAnimationFrame?cancelAnimationFrame(a.value):clearInterval(a))};a.setTimeout=function(a,
b){function c(){(new Date).getTime()-l>=b?a.call():g.value=requestAnimationFrame(c)}if(!requestAnimationFrame)return setTimeout(a,b);var l=(new Date).getTime(),g={};g.value=requestAnimationFrame(c);return g};a.clearTimeout=function(a){a&&(cancelAnimationFrame?cancelAnimationFrame(a.value):clearTimeout(a))};a.showAbout=function(){var b="<html>\n<head>\n<style>\nbody{text-align:center;}\niframe{width:650px;height:73px;overflow:hidden;border:1px solid black;}\ndt{font-weight:bold;margin-top:10px;}\n</style>\n</head>\n<body>\n<iframe src='http://arquimedes.matem.unam.mx/Descartes5/creditos/bannerPatrocinadores.html'></iframe>\n<h2><a href='http://proyectodescartes.org/' target='_blank'>ProyectoDescartes.org</a><br><a href='http://descartesjs.org' target='_blank'>DescartesJS.org</a></h2>\n<dl>\n<dt>Dise\u00f1o funcional:</dt>\n<dd>\n<nobr>Jos\u00e9 Luis Abreu Leon,</nobr>\n<nobr>Jos\u00e9 R. Galo Sanchez,</nobr>\n<nobr>Juan Madrigal Muga</nobr>\n</dd>\n<dt>Autores del software:</dt>\n<dd>\n<nobr>Jos\u00e9 Luis Abreu Leon,</nobr>\n<nobr>Marta Oliver\u00e1 Serrat,</nobr>\n<nobr>Oscar Escamilla Gonz\u00e1lez,</nobr>\n<nobr>Joel Espinosa Longi</nobr>\n</dd></dl>\n<p>\nEl software en Java est\u00e1 bajo la licencia\n<a href='https://joinup.ec.europa.eu/software/page/eupl/licence-eupl'>EUPL v.1.1</a>\n<br>\nEl software en JavaScript est\u00e1 bajo licencia\n<a href='http://www.gnu.org/licenses/lgpl.html'>LGPL</a>\n</p>\n<p>\nLa documentaci\u00f3n y el c\u00f3digo fuente se encuentran en :\n<br>\n<a href='http://descartes.matem.unam.mx/'>http://descartes.matem.unam.mx/</a>\n</p>";
a.ccLicense&&(b+="<p>\nEste objeto, creado con Descartes, est\u00e1 licenciado\npor sus autores como\n<a href='https://creativecommons.org/licenses/by-nc-sa/4.0/deed.es'><nobr>Creative Commons</nobr></a>\n<br>\n<a href='https://creativecommons.org/licenses/by-nc-sa/4.0/deed.es'><img src='https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png'></a>\n</p>");b+="</body> </html>";var c=window.open("","creditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0");
c.document.write(b);c.document.close()};a.splitSeparator=function(a){a=a.replace(/\\n/g,"\n");for(var b=!1,c,l=[],g=0,d=0,f=a.length;d<f;d++)c=a.charAt(d),"'"===c&&(b=!b),b||";"!==c&&"\n"!==c||(l.push(a.substring(g,d).replace(/\n/g,"\\n")),g=d+1);l.push(a.substring(g).replace(/\n/g,"\\n"));return l};a.preventDefault=function(a){a.preventDefault();return!1};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k;a.cacheFiles={};a.openExternalFile=function(f){if(a.cacheFiles[f])return a.cacheFiles[f];h=null;k=new XMLHttpRequest;k.open("GET",f,!1);try{k.send(null),h=200===k.status||304===k.status?k.responseText:k.responseText||"",h=404===k.status?"":h,h.match(String.fromCharCode(65533))&&(k.open("GET",f,!1),k.overrideMimeType("text/plain;charset=ISO-8859-1"),k.send(null),h=k.responseText)}catch(n){h=null}return h};a.addExternalFileContent=function(f,h){a.cacheFiles[f]=
h};return a}(descartesJS||{});
descartesJS=function(a){function h(a){u=a.indexOf("--radial--");-1!=u&&(a=a.substring(0,u));e=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};e[0]==e[e.length-1]&&"'"==e[0]&&(a.ignoreCaps=!0,e=e.substring(1,e.length-1),"`"==e[0]&&"\u00b4"==e[e.length-1]&&(a.ignoreAcents=!0,e=e.substring(1,e.length-1)));"`"==e[0]&&"\u00b4"==e[e.length-1]&&(a.ignoreAcents=!0,e=e.substring(1,e.length-1),e[0]==e[e.length-1]&&"'"==e[0]&&(a.ignoreCaps=!0,e=e.substring(1,e.length-1)));"*"===e.charAt(0)&&"*"!==e.charAt(e.length-
1)?e=e.substring(1)+"$":"*"!==e.charAt(0)&&"*"===e.charAt(e.length-1)?e="^"+e.substring(0,e.length-1):"*"!==e.charAt(0)&&"*"!==e.charAt(e.length-1)?e="^"+e+"$":"*"===e.charAt(0)&&"*"===e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));a.regExp=e.replace(/\?/g,"[\\S\\s]{1}");return a}function k(a,b){e=(a||"").trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=e.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 f(a,c,d){c=parseFloat(c);r=a.expr[0];g=a.expr[1];b=d.eval(r.expr);l=d.eval(g.expr);w="("==r.type||"["==r.type;q=")"==g.type||"]"==g.type;return w&&c>b&&q&&c<=l?1:0}function n(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 e,m,d,c,r,g,b,l,w,q,u;a.buildRegularExpresionsPatterns=function(a,b){a=a||"";"("===a.charAt(0)&&")"===a.charAt(a.length-1)&&-1===a.indexOf(",")&&(a=a.substring(1,a.length-1));a=a.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|");for(var c=0,l=a.length;c<l;c++){m=a[c].split("&");d=[];for(var g=0,f=m.length;g<f;g++)e=m[g],-1===e.indexOf(",")||"("!==
e.charAt(0)&&"["!==e.charAt(0)||")"!==e.charAt(e.length-1)&&"]"!==e.charAt(e.length-1)?d.push(h(e)):d.push(k(e,b));a[c]=d}return a};a.escorrecto=function(b,l,g,d){g=g||a.externalEvaluator;d=d||a.buildRegularExpresionsPatterns(b,g);l=n(l);b=0;for(var e=d.length;b<e;b++){m=d[b];c=!0;for(var h=0,k=m.length;h<k;h++)c=m[h].regExp?c&&!!l.match(new RegExp(n(m[h].regExp),"i")):c&&f(m[h],l,g);if(c)return 1}return 0};a.esCorrecto=function(b,l,g,d){g=g||a.externalEvaluator;d=d||a.buildRegularExpresionsPatterns(b,
g);b=0;for(var h=d.length;b<h;b++){m=d[b];c=!0;for(var k=0,p=m.length;k<p;k++)(e=m[k].regExp)?(m[k].ignoreAcents&&(l=n(l),e=n(e)),m[k].ignoreCaps&&(l=l.toLowerCase(),e=n(e).toLowerCase()),c=c&&!!l.match(e)):c=c=c&&f(m[k],l,g);if(c)return 1}return 0};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.loaderImg=new Image;a.loaderImg.src="data:image/svg+xml;base64, ";a.getCCLImg=
function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAMAAABUFvrSAAABC1BMVEUAAAC1urSEhYRDREMNDg2EhoR5fHkpKSmRk5EbGxuRlJGVmZQoKShAQEBwcHCTmJNQUVAQEBBgYGCAgIC/v78ODg5QUFDf39/////v7++fn5+Rj49aV1jj4+PIx8cwMDB9f3zW1dUyMTGamJkZGRkNDA12c3SjoaEjHyC6ubkpKikoJSY/OzxoZWaHhoesq6s/NzljX2HPz891cnN4dXbx8fGflpqOh4uenZ0xLS4kJCQoKCjo5+ePj4+1tbUtLS3g3+Cvr6/JyMggICAqKip+e3wfGxyEgYIqJyeYlpd/gX5ubGyMiovLyst6fXmeoJ18f3xdXl2ChYJwcm81NjWWmZYyMzE+Pz6JjIk4KLQtAAACcklEQVR4AbyVhXbjMBREx2UIGWq/MCcqMy2Wu8z0/1+yz5ElKyrjlG99bpQR4eniPEmeRTwyOgbO2Oi4Y2ViEpzJiTuQVDw1DZ3pGVM7mwGyuVwWyOQlyd9MtLgAwPX8IPA9F0DBEM8hjIgThZjL35YAUF7XL5JMidUZ7Z2ExwyI/yFxZkDKFYtUa7WqJgASbz0inWI9HXMDYVOJKcQEt4lWm72dbq+qCT/TF5x5SZR4ir1quNqc9LyAKOURJuO3sCiWluGvYFWTiGpibb0nRFmSRDwNd4OGUnQxLcXIEscDPOJkEZPNLSFEr9pMCW3viF2iPbEviRSPAD5ZKQFy1SFHHEB2kYMktR6AXjMl2y/ES65ZiFdMlHgULhcRhNmsL3+8JiIXo9eI2dHbF6Iyr8mbt8FAfGCIx+CxEHGyh+DEf3sYu7wKSbb3qCk4S4rM94+IVoUwqwB4iHUcR8FxqY56dHhcGnQxEJ/IyQOMyWNSEfv76K2enimyJ8T5+Tvx3pw8ICBKetZ1B4n4A0KylxuT6nmnW942ybngfNyW5EYxZyHdIDlzg3yqWOTz6mpTEruK4saxz1XEP2QVD9zScvKSWdOTl8NYuqlR93J1dcBwMjcRKS7AJb3cDrODH3SMUUflyz2PzSnu4tIN8oDoLR1dvqUfKP562SE09VAxvjnOdzYbx1Akj80feGB+Dh/0Rd8FfjnONzw4jXjM9tX0Gypyf0B+cfQfzK2H6KL5q3mZTpleUPJJKZF/Wy+lgNWGM6Wu/xlnuAd1bBok+TCijhNY+eMM5S+M2EVIQvYALaDz95+y/jO1l49Yy+15IPzfkAUAdrZiwIT3fTYAAAAASUVORK5CYII=";
return a};a.getSvgMenu=function(){return"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCI+PHBhdGggZD0iTTYuNjQgOEwxMiAxMi45NjIgMTcuMzYgOCAxOSA5LjUxOSAxMiAxNiA1IDkuNTE5eiIvPjwvc3ZnPg=="};a.getSvgCheckbox=function(){return"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0NSIgaGVpZ2h0PSI0NSI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzcuMDk1IDYuMjg0TDE1LjQ3MyAyNy45MDVsLTcuNTY4LTcuNTY3TDIuNSAyNS43NDNsMTIuOTczIDEyLjk3M0w0Mi41IDExLjY5eiIgY29sb3I9IiMwMDAiIHNvbGlkLWNvbG9yPSIjMDAwMDAwIiBzdHlsZT0iYmxvY2stcHJvZ3Jlc3Npb246dGI7aXNvbGF0aW9uOmF1dG87bWl4LWJsZW5kLW1vZGU6bm9ybWFsO3RleHQtZGVjb3JhdGlvbi1jb2xvcjojMDAwO3RleHQtZGVjb3JhdGlvbi1saW5lOm5vbmU7dGV4dC1kZWNvcmF0aW9uLXN0eWxlOnNvbGlkO3RleHQtaW5kZW50OjA7dGV4dC10cmFuc2Zvcm06bm9uZSIgd2hpdGUtc3BhY2U9Im5vcm1hbCIvPjwvc3ZnPg=="};
a.symbolFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.extraBFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.extraBIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.extraIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.extraRFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.arimoBFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.arimoBIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.arimoIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.arimoRFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.cousineBFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.cousineBIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.cousineIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.cousineRFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.tinosBFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.tinosBIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.tinosIFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
a.tinosRFont=function(){return"data:font/woff2;charset=utf-8;base64, "};
return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,k=Math.min,f,n,e,m,d,c,r,g,b,l,w,q,u,x;a.Color=function(b,l){this.b=this.g=this.r=0;this.a=1;this.evaluator=l;this.getColor=this.getColorStr;if(b){if(babel[b]&&("net"===babel[b]&&(b="rojo"),b=babel[b],this.r=a.toHex(b.substring(1,3)),this.g=a.toHex(b.substring(3,5)),this.b=a.toHex(b.substring(5,7)),this.colorStr=b),6===b.length&&(this.r=a.toHex(b.substring(0,2)),this.g=a.toHex(b.substring(2,4)),this.b=a.toHex(b.substring(4,6)),this.colorStr=
"#"+b),8===b.length&&(this.r=a.toHex(b.substring(2,4)),this.g=a.toHex(b.substring(4,6)),this.b=a.toHex(b.substring(6,8)),this.a=1-a.toHex(b.substring(0,2))/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")"),"("===b[0]){n=[];e=this.splitComa(b.substring(1,b.length-1));b=0;for(l=e.length;b<l;b++)c=e[b],m=parseInt(c,16),c!==m.toString(16)&&c!=="0"+m.toString(16)?("["===c.charAt(0)&&"]"===c.charAt(c.length-1)&&(c=c.substring(1,c.length-1)),n.push(this.evaluator.parser.parse(c))):n.push(this.evaluator.parser.parse((m/
255).toString()));this.rExpr=n[0];this.gExpr=n[1];this.bExpr=n[2];this.aExpr=n[3];this.getColor=this.getColorExp}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.splitComa=function(a){d=[];for(var c=b=g=r=0,f=a.length;c<f;c++)l=a.charAt(c),"("===l?r++:")"===l?r--:"["===l?g++:"]"===l?g--:","===l&&0===r&&0===g&&(d.push(a.substring(b,c)),b=c+1);d.push(a.substring(b));return d};a.Color.prototype.getColorStr=function(){return this.colorStr};a.Color.prototype.getColorExp=
function(){f=this.evaluator;this.r=k(255,h(255*f.eval(this.rExpr)));this.g=k(255,h(255*f.eval(this.gExpr)));this.b=k(255,h(255*f.eval(this.bExpr)));this.a=1-f.eval(this.aExpr);return"rgba("+this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"#ffffff":"#000000"};a.toHex=function(a){return parseInt("0x"+a,16)};a.RGBAToHexColor=function(b){b=b.substring(5,b.length-1).split(",");w=(b[0]>>0).toString(16);q=(b[1]>>0).toString(16);u=(b[2]>>
0).toString(16);x=(255-(255*parseFloat(b[3])>>0)).toString(16);1===w.length&&(w="0"+w);1===q.length&&(q="0"+q);1===u.length&&(u="0"+u);1===x.length&&(x="0"+x);return new a.Color(x+w+q+u)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=document.head,k=document.createElement("meta");k.setAttribute("http-equiv","X-UA-Compatible");k.setAttribute("content","IE=edge,chrome=1");h.appendChild(k);k=document.createElement("meta");k.setAttribute("name","viewport");k.setAttribute("content","width=device-width,initial-scale=1.0,user-scalable=yes");document.querySelector("meta[name=viewport]")||h.appendChild(k);k=document.createElement("meta");k.setAttribute("name","apple-mobile-web-app-capable");
k.setAttribute("content","yes");h.appendChild(k);k=document.createElement("meta");k.setAttribute("name","apple-mobile-web-app-status-bar-style");k.setAttribute("content","black");h.appendChild(k);k=document.createElement("meta");k.setAttribute("name","DescartesJS_author");k.setAttribute("content","Joel Espinosa Longi");h.appendChild(k);(h=document.getElementById("StyleDescartesApps2"))&&h.parentNode.removeChild(h);h=document.createElement("style");h.type="text/css";h.id="StyleDescartesApps2";h.setAttribute("rel",
"stylesheet");document.head.insertBefore(h,document.head.firstChild);h.innerHTML="body{-webkit-overflow-scrolling:touch;}\n@font-face{font-family:'DJS_symbola';src:url('"+a.symbolFont()+"') format('woff2');font-style:normal;font-weight:bold;}\n@font-face{font-family:'DJS_symbola';src:url('"+a.symbolFont()+"') format('woff2');font-style:italic;font-weight:bold;}\n@font-face{font-family:'DJS_symbola';src:url('"+a.symbolFont()+"') format('woff2');font-style:italic;font-weight:normal;}\n@font-face{font-family:'DJS_symbola';src:url('"+
a.symbolFont()+"') format('woff2');font-style:normal;font-weight:normal;}\n@font-face{font-family:'DJS_extra';src:url('"+a.extraBFont()+"') format('woff2');font-style:normal;font-weight:bold;}\n@font-face{font-family:'DJS_extra';src:url('"+a.extraBIFont()+"') format('woff2');font-style:italic;font-weight:bold;}\n@font-face{font-family:'DJS_extra';src:url('"+a.extraIFont()+"') format('woff2');font-style:italic;font-weight:normal;}\n@font-face{font-family:'DJS_extra';src:url('"+a.extraRFont()+"') format('woff2');font-style:normal;font-weight:normal;}\n@font-face{font-family:'DJS_sansserif';src:url('"+
a.arimoBFont()+"') format('woff2');font-style:normal;font-weight:bold;}\n@font-face{font-family:'DJS_sansserif';src:url('"+a.arimoBIFont()+"') format('woff2');font-style:italic;font-weight:bold;}\n@font-face{font-family:'DJS_sansserif';src:url('"+a.arimoIFont()+"') format('woff2');font-style:italic;font-weight:normal;}\n@font-face{font-family:'DJS_sansserif';src:url('"+a.arimoRFont()+"') format('woff2');font-style:normal;font-weight:normal;}\n@font-face{font-family:'DJS_monospace';src:url('"+a.cousineBFont()+
"') format('woff2');font-style:normal;font-weight:bold;}\n@font-face{font-family:'DJS_monospace';src:url('"+a.cousineBIFont()+"') format('woff2');font-style:italic;font-weight:bold;}\n@font-face{font-family:'DJS_monospace';src:url('"+a.cousineIFont()+"') format('woff2');font-style:italic;font-weight:normal;}\n@font-face{font-family:'DJS_monospace';src:url('"+a.cousineRFont()+"') format('woff2');font-style:normal;font-weight:normal;}\n@font-face{font-family:'DJS_serif';src:url('"+a.tinosBFont()+"') format('woff2');font-style:normal;font-weight:bold;}\n@font-face{font-family:'DJS_serif';src:url('"+
a.tinosBIFont()+"') format('woff2');font-style:italic;font-weight:bold;}\n@font-face{font-family:'DJS_serif';src:url('"+a.tinosIFont()+"') format('woff2');font-style:italic;font-weight:normal;}\n@font-face{font-family:'DJS_serif';src:url('"+a.tinosRFont()+"') format('woff2');font-style:normal;font-weight:normal;}\n.PBL{position:absolute;background-color:#f2f2f2;border:none;-webkit-appearance:none;-moz-apearance:none;apearance:none;color:#2daae4;visibility:hidden;border-radius:100vw;}\n.PBL::-moz-progress-bar{background:#2daae4;border-radius:inherit;}\n.PBL::-webkit-progress-bar{background:#f2f2f2;border-radius:100vw;}\n.PBL::-webkit-progress-value{background:#2daae4;border-radius:inherit;}\n.PBL::-ms-fill{background:#2daae4;border-radius:inherit;}\ncanvas{transform:translate3d(0,0,0);}\ndiv.DescartesAppContainer html,div.DescartesAppContainer *,div.DescartesAppContainer *:before,div.DescartesAppContainer *:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}\ndiv.DescartesCatcher{background-color:rgba(255,255,255,0);cursor:pointer;position:absolute;}\ndiv.DescartesAppContainer{border:0 solid #000;overflow:hidden;position:relative;top:0;left:0;}\ndiv.DescartesLoader{background-color:#fff;overflow:hidden;position:absolute;top:0;left:0;}\ndiv.DescartesLoaderImage{position:absolute;background-repeat:no-repeat;background-position:center;overflow:hidden;top:0;left:0;width:100%;height:100%;}\ncanvas.DescartesLoaderBar{position:absolute;overflow:hidden;top:0;left:0;}\ncanvas.DescartesSpace2DCanvas,canvas.DescartesSpace3DCanvas,div.blocker{touch-action:none;position:absolute;overflow:hidden;left:0;top:0;}\ndiv.DescartesSpace2DContainer,div.DescartesSpace3DContainer{position:absolute;overflow:hidden;line-height:0;}\n.DescartesCheckboxContainer input[type=checkbox],.DescartesCheckboxContainer input[type=radio]{display: none;}\n.DescartesCheckboxContainer input[type=checkbox]+label::after,.DescartesCheckboxContainer input[type=radio]+label::after{position:absolute;left:0px;content:'';padding:0;margin:0;width:100%;height:100%;background:white;border: 1px solid gray;}\n.DescartesCheckboxContainer input[type=checkbox]:checked+label::after,.DescartesCheckboxContainer input[type=radio]:checked+label::after{content:'';background:url("+
a.getSvgCheckbox()+") center center no-repeat;background-size:contain;background-color:white;}\ncanvas.DescartesButton{position:absolute;cursor:pointer;}\ndiv.DescartesButtonContainer{position:absolute;overflow:hidden;}\ndiv.DescartesButtonContainer div{display:inline-flex;justify-content:center;align-items:center;width:100%;height:100%;}\ndiv.DescartesButtonContainer[data-active='false']::after{content:' ';position:absolute;left:0;top:0;width:100%;height:100%;background:rgba(240,240,240,0.6);pointer-events:none;}\ndiv.DescartesSpinnerContainer,div.DescartesCheckboxContainer,div.DescartesTextFieldContainer,div.DescartesMenuContainer{background:lightgray;position:absolute;overflow:hidden;}\ndiv.DescartesSpinnerContainer input,div.DescartesCheckboxContainer,div.DescartesTextFieldContainer input,div.DescartesMenuContainer select{border-radius:0;}\n.DescartesCheckbox{position:absolute;}\ninput.DescartesSpinnerField,input.DescartesTextFieldField,input.DescartesMenuField,input.DescartesScrollbarField{font-family:"+
a.sansserif_font+";padding:0 2px;border:solid #666 1px;position:absolute;top:0;}\nlabel.DescartesSpinnerLabel,label.DescartesCheckboxLabel,label.DescartesMenuLabel,label.DescartesScrollbarLabel,label.DescartesTextFieldLabel{font-family:"+a.sansserif_font+";font-weight:normal;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;background-color:#e0e4e8;position:absolute;left:0;top:0;}\ndiv.DescartesGraphicControl{touch-action:none;border-style:none;position:absolute;}\ndiv.DescartesTextAreaContainer{position:absolute;overflow:hidden;background:#F7F7F7;}\nselect.DescartesMenuSelect{font-family:"+
a.sansserif_font+";padding-top:0;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;position:absolute;border:1px solid #7a8a99; background:#fff url('"+a.getSvgMenu()+"') 100%/22px no-repeat;padding:0 22px 0 5px;-webkit-appearance:none;-moz-appearance:none;appearance:none;}\nselect.DescartesMenuSelect::-ms-expand{display:none;}\ndiv.DescartesScrollbarContainer{touch-action:none;background:#eee;overflow:hidden;position:absolute;}\n";return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.sin,k=Math.floor,f=Math.random,n=Math.round,e=Math.abs,m=String.fromCharCode,d,c,r,g,b,l,w,q,u,x;a.Krypto=function(a){this.key=(void 0===a?0:a).toString()};a.Krypto.prototype.getKey=function(a){d=[];for(var b=0;256>b;b++)d[b]=m(this.alfanum(k(e(7.5*(h(1*b-a)+h(1.4*b+a)+h(.6*b-a)+h(2.2*b+a))))));return d.join("")};a.Krypto.prototype.encode=function(a){c=k(31*f());this.key=this.getKey(c);return m(this.alfanum(c))+this.encripta(a)};a.Krypto.prototype.decode=
function(a){c=this.numalfa(a.charCodeAt(0));this.key=this.getKey(c);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;l=Array(3*a.length);for(var b=0,c=a.length;b<c;b++)u=256*k(a[b]+128)+n(255*f())+65536*n(255*f()),x=k((u<<this.shift(b))/256),l[3*b]=this.alfanum(x%32),l[3*b+1]=this.alfanum(x/32%32),l[3*b+2]=this.alfanum(x/
1024%32);return l};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;w=Array(a.length/3);for(var b=0,c=w.length;b<c;b++)x=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),u=k(256*x>>this.shift(b)),q=k(u/256)%256-128,0>q&&(q+=256),w[b]=q;return w};a.Krypto.prototype.alfanum=function(a){return(10>a?48:87)+k(a)};a.Krypto.prototype.numalfa=
function(a){return a-(58>a?48:87)};a.Krypto.prototype.stringToBytes=function(a){g=[];for(var b=0,c=a.length;b<c;b++)g.push(a.charCodeAt(b));return g};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=m(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){r=this.key.charCodeAt(a%this.key.length);g=this.numalfa(r);b=k(g/2%8);0==b&&(b=4);return b};a.Krypto.prototype.parseByte=function(a){a=parseInt(a);a=0>a?0:a;return 255<a?255:a};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.max;a.Animation=function(h,f){this.parent=h;var k=h.evaluator,e=k.parser;h=new a.Auxiliary(h);var m=this;m.delay=f.delay?e.parse(f.delay):e.parse("60");m.loop=f.loop?f.loop:!1;m.auto=void 0==f.auto?!0:f.auto;m.controls=f.controls;m.init=h.splitInstructions(e,f.init);m.doExpr=h.splitInstructions(e,f.doExpr);f.whileExpr&&(m.whileExpr=e.parse(f.whileExpr));var d,c=m.doExpr.length;m.animExec=function(){for(d=0;d<c;d++)k.eval(m.doExpr[d]);m.parent.update();
m.playing&&(0<k.eval(m.whileExpr)||m.loop)?m.timer=a.setTimeout(m.animExec,k.eval(m.delay)):(m.stop(),m.pause=!1,m.parent.update())};m.playing=!1;m.auto&&m.play()};a.Animation.prototype.play=function(){this.playing?(this.pause=!0,this.stop()):(this.pause||this.reinit(),this.playing=!0,this.pause=!1,this.timer=a.setTimeout(this.animExec,h(10,this.parent.evaluator.eval(this.delay))))};a.Animation.prototype.stop=function(){this.playing=!1;a.clearTimeout(this.timer)};a.Animation.prototype.reinit=function(){for(var a=
0,f=this.init.length;a<f;a++)this.parent.evaluator.eval(this.init[a])};return a}(descartesJS||{});descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,k){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Message=function(h,k){a.Action.call(this,h,k);this.parameter=(k||"").replace(/\\n/g,"\n").replace(/&squot;/g,"'")};a.extend(a.Message,a.Action);a.Message.prototype.execute=function(){alert(this.parameter)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Calculate=function(h,k){a.Action.call(this,h,k);var f=this.evaluator;h=f.parser;k=(k||"").replace(/&squot;/g,"'");k=a.splitSeparator(k);for(var n=[],e,m=0,d=k.length;m<d;m++)(e=h.parse(k[m],!0))&&n.push(e);d=n.length;this.execute=function(){for(m=0;m<d;m++)f.eval(n[m])}};a.extend(a.Calculate,a.Action);return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(h,k){a.Action.call(this,h,k);this.parser=h.evaluator.parser;this.evaluator=h.evaluator;this.parameter=k;this.target="_blank"};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){var h=this.parameter;"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=this.evaluator.eval(this.parser.parse(h.substring(1,h.length-1))));var k=h.indexOf("target");-1!=k&&(this.target=h.substring(k),this.target=this.target.substring(this.target.indexOf("=")+
1),h=h.substring(0,k-1));if("javascript"==h.substring(0,10)){h=new a.SimpleText(parent,h.substring(11).replace(/&squot;/g,"'"));try{eval(h.toString())}catch(f){}}else"http"!=h.substring(0,4)&&(k=window.__dirname||window.location.href,h=k.substring(0,k.lastIndexOf("/")+1)+h),window.open(h,this.target)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(h,k){a.Action.call(this,h,k);this.parser=h.evaluator.parser;this.evaluator=h.evaluator;this.parameter=k.trim();this.target="_blank"};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){var a=this.parameter;"["===a.charAt(0)&&"]"===a.charAt(a.length-1)&&(a=this.evaluator.eval(this.parser.parse(a.substring(1,a.length-1))));var k=a.indexOf("target");-1!=k&&(this.target=a.substring(k),this.target=this.target.substring(this.target.indexOf("=")+
1),a=a.substring(0,k-1));if("javascript"==a.substring(0,10)){a=a.substring(11).replace(/&squot;/g,"'");try{eval(a.toString())}catch(f){}}else"http"!=a.substring(0,4)&&(k=window.__dirname||window.location.href,a=k.substring(0,k.lastIndexOf("/")+1)+a),window.open(a,this.target,"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0")};
return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Config=function(h,k){a.Action.call(this,h,k)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){this.parent.editor?this.parent.editor.show():window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'><script type='text/javascript' src='http://arquimedes.matem.unam.mx/Descartes5/lib/descartes-min.js'>\x3c/script>\n"+this.parent.applet.outerHTML.replace(/<applet/g,
"<ajs").replace(/<\/applet/g,"</ajs")+"</xmp>")};return a}(descartesJS||{});descartesJS=function(a){if(a.loadLib)return a;a.Init=function(h,k){a.Action.call(this,h,k)};a.extend(a.Init,a.Action);a.Init.prototype.execute=function(){this.parent.init()};return a}(descartesJS||{});descartesJS=function(a){if(a.loadLib)return a;a.Clear=function(h,k){a.Action.call(this,h,k)};a.extend(a.Clear,a.Action);a.Clear.prototype.execute=function(){this.parent.clear()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Animate=function(h,k){a.Action.call(this,h,k)};a.extend(a.Animate,a.Action);a.Animate.prototype.execute=function(){this.parent.play()};return a}(descartesJS||{});descartesJS=function(a){if(a.loadLib)return a;a.InitAnimation=function(h,k){a.Action.call(this,h,k)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;a.PlayAudio=function(k,f){a.Action.call(this,k,f);f=f||"";f.match(h)?this.filenameExpr=this.evaluator.parser.parse("'"+f.match(h)+"'"):(""!==f&&"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1)),this.filenameExpr=this.evaluator.parser.parse(f))};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.eval(this.filenameExpr));
a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,h){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var f in h)h.hasOwnProperty(f)&&(this[f]=h[f])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var h,k;a.Auxiliary.prototype.splitInstructions=function(f,n){k=[];n=n?a.splitSeparator(n):[""];for(var e=0,m=n.length;e<m;e++)a.DEBUG.lineCount=e,(h=f.parse(n[e],!0))&&k.push(h);
return k};a.Auxiliary.prototype.getPrivateVariables=function(a,n){k=[];n=n?n.split(/;|,/):[""];for(var f=0,m=n.length;f<m;f++)(h=a.parse(n[f],!0))&&k.push(h);f=0;for(m=k.length;f<m;f++)k[f]="asign"===k[f].type?k[f].childs[0].value:"identifier"===k[f].type?k[f].value:"";return k};a.Auxiliary.prototype.parseExpressions=function(f){a.DEBUG.paramName="inicio";this.init=this.splitInstructions(f,this.init);a.DEBUG.paramName="local";this.privateVars=this.getPrivateVariables(f,this.local);a.DEBUG.paramName=
"hacer";this.doExpr=this.splitInstructions(f,this.doExpr);a.DEBUG.paramName="mientras";this.whileExpr=f.parse(this.whileExpr)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(h,k){a.Auxiliary.call(this,h,k);h=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=h.parse(this.expresionString))&&h.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"),k=document.createElement("label");k.appendChild(document.createTextNode("___"+
this.id+"=___"));var f=document.createElement("input");f.value=this.expresionString;f.disabled=!this.editable;a.appendChild(k);a.appendChild(f);var n=this,e=n.evaluator.parser;f.onkeydown=function(a){13==a.keyCode&&(n.expresion=e.parse(this.value),e.setVariable(n.id,n.expresion),n.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(h,k){a.Auxiliary.call(this,h,k);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.eval(this.expresion))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f;a.Vector=function(f,e){h=f.evaluator;k=h.parser;this.size=k.parse("3");a.Auxiliary.call(this,f,e);this.expresion=this.expresion.split(";");this.parseFile=k.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var n=this.expresion;h=this.evaluator;k=h.parser;this.oldFile=this.file;if(f=h.eval(this.parseFile))this.file=f;if(this.file){var e=(vectorElement=document.getElementById(this.file))&&"descartes/vectorFile"==
vectorElement.type?vectorElement.text:a.openExternalFile(this.file);if(null!=e){e=e.replace(/\r/g,"").split("\n");for(var m=[],d=0,c=e.length;d<c;d++)""!=e[d]&&m.push(e[d]);e=m}null==e||1==e.length&&""==e[0]?this.size=k.parse("0"):(n=e,this.size=null);null===this.size&&(this.size=k.parse(n.length+""))}e=[];d=0;for(c=n.length;d<c;d++)(m=k.parse(n[d],!0))&&"asign"!=m.type&&(m=k.parse(this.id+"["+d+"]="+n[d],!0)),e.push(m);n=[];n._size_=h.eval(this.size);d=0;for(c=this._size_;d<c;d++)n.push(0);h.vectors[this.id]=
n;h.setVariable(this.id+".long",n._size_);d=0;for(c=e.length;d<c;d++)h.eval(e[d])};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(h,k){var f=h.evaluator,n=f.parser;this.rows=n.parse("3");this.columns=n.parse("3");a.Auxiliary.call(this,h,k);this.expresion=this.splitInstructions(n,this.expresion);h=f.eval(this.rows);k=f.eval(this.columns);n=[];n.type="matrix";for(var e,m=0;m<k;m++){e=[];for(var d=0,c=h;d<c;d++)e.push(0);n[m]=e}f.matrices[this.id]=n;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,k=a.eval(this.rows),
f=a.eval(this.columns);a.setVariable(this.id+".filas",k);a.setVariable(this.id+".columnas",f);var n=a.matrices[this.id];n.rows=k;n.cols=f;k=0;for(f=this.expresion.length;k<f;k++)a.eval(this.expresion[k])};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Function=function(h,k){a.Auxiliary.call(this,h,k);var f=this.evaluator;h=f.parser;k=this.id.indexOf("(");this.name=this.id.substring(0,k);this.params=this.id.substring(k+1,this.id.indexOf(")"));this.domain=this.range?h.parse(this.range):h.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(h);this.expresion=h.parse(this.expresion);
var n=this;this.functionExec=function(){n.iterations=0;if(n.numberOfParams<=arguments.length){for(var e=[],h=0,d=n.privateVars.length;h<d;h++)e.push(f.getVariable(n.privateVars[h])),f.setVariable(n.privateVars[h],0);var c=[];h=0;for(d=n.params.length;h<d;h++)c[h]=f.getVariable(n.params[h]),f.setVariable(n.params[h],arguments[h]);h=0;for(d=n.init.length;h<d;h++)f.eval(n.init[h]);do{h=0;for(d=n.doExpr.length;h<d;h++)f.eval(n.doExpr[h]);if(1E5<++n.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n << "+
n.name+" >>"),0}while(0<f.eval(n.whileExpr));var k=f.eval(n.expresion);a.rangeOK=f.eval(n.domain);h=0;for(d=n.params.length;h<d;h++)f.setVariable(n.params[h],c[h]);h=0;for(d=n.privateVars.length;h<d;h++)f.setVariable(n.privateVars[h],e[h]);return k}return 0};f.setFunction(this.name,this.functionExec)};a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.JsFunction=function(h,k){this.code="";a.Auxiliary.call(this,h,k);h=this.evaluator;k=this.id.indexOf("(");this.name=this.id.substring(0,k);this.params=this.id.substring(k+1,this.id.indexOf(")"));this.params=""===this.params?[]:this.params.split(",");this.functionCode=this.code.replace(/\\;/g,";")+";\nreturn "+(this.expresion||0)+";";this.functionExec=new Function(this.params,this.functionCode);h.setFunction(this.name,this.functionExec)};a.extend(a.JsFunction,
a.Auxiliary);return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(h,k){a.Auxiliary.call(this,h,k);var f=this.evaluator;this.parseExpressions(f.parser);var n=this;this.algorithmExec=function(){for(var a=n.iterations=0,h=n.init.length;a<h;a++)f.eval(n.init[a]);do{a=0;for(h=n.doExpr.length;a<h;a++)f.eval(n.doExpr[a]);if(1E5<++n.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en el algoritmo << "+n.name+" >>"),0}while(0<f.eval(n.whileExpr))}};a.extend(a.Algorithm,
a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"===this.evaluate&&(this.update=function(){})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Event=function(h,k){a.Auxiliary.call(this,h,k);h=this.evaluator;delete this.evaluate;this.condition=h.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<this.evaluator.eval(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<this.evaluator.eval(this.condition);
3==this.parent.version?a!=this.lastEvaluation&&(this.action.execute(),this.lastEvaluation=a?!0:!1):a&&!this.lastEvaluation?(this.action.execute(),this.lastEvaluation=!0):!a&&this.lastEvaluation&&(this.lastEvaluation=!1)});"always"==this.execution&&(this.eventExec=function(){0<this.evaluator.eval(this.condition)&&this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Library=function(h,k){a.Auxiliary.call(this,h,k);if(k=k.file){var f=document.getElementById(k);response=f&&"descartes/library"==f.type?f.text:a.openExternalFile(k)}if(response)for(response=response.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,
"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&").replace(/\r/g,"").split("\n"),k=0,f=response.length;k<f;k++)""!==response[k].trim()&&h.lessonParser.parseAuxiliar(response[k])};a.extend(a.Library,a.Auxiliary);return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c;a.Graphic=function(c,g){this.parent=c;this.evaluator=c.evaluator;var b=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=b.parse("1");this.abs_coord=g.type&&"text"===g.type?!0:!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=b.parse("(0,0)");this.family="";this.family_interval=
b.parse("[0,1]");this.family_steps=b.parse("8");this.editable=this.visible=!1;this.font="SansSerif,PLAIN,"+(5<=this.parent.version?"18":"12");this.fixed=!0;this.text="";this.decimals=b.parse("2");for(var l in g)g.hasOwnProperty(l)&&(this[l]=g[l]);this.space=this.getSpace();this.canvas=this.background?this.space.backCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backCtx);this.font_str=this.font;this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=
this.font.match(/([\d\.]+)px/))?parseFloat(this.fontSize[1]):10;this.font_style=a.getFontStyle(this.font_str.split(",")[1]);if("boolean"===typeof this.bold||"boolean"===typeof this.italics)this.bold&&!this.italics?this.font_style="Bold ":!this.bold&&this.italics?this.font_style="Italic ":this.bold&&this.italics?this.font_style="Italic Bold ":this.bold||this.italics||(this.font_style=" ");this.font_family||(this.font_family=this.font_str.split(",")[0]);this.font_family=a.getFontName(this.font_family);
"undefined"===typeof this.font_size&&(this.font_size=c.evaluator.parser.parse(this.fontSize.toString()))};a.Graphic.prototype.getSpace=function(){var a=this;return this.parent.spaces.find(function(c){return c.id===a.spaceID})||this.parent.spaces[0]};a.Graphic.prototype.getFamilyValues=function(){h=this.evaluator;k=h.eval(this.family_interval);this.familyInf=k[0][0];this.familySup=k[0][1];this.fSteps=Math.round(h.eval(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/
this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,c,b){h=this.evaluator;this.getFamilyValues();f=h.getVariable(this.family);if(0<=this.fSteps)for(var l=0,g=this.fSteps;l<=g;l++)h.setVariable(this.family,this.familyInf+l*this.family_sep),0<h.eval(this.drawif)&&(this.update(),a.oldTextNode=null,this.drawAux(a,c,b));h.setVariable("_Text_H_",0);h.setVariable(this.family,f)};a.Graphic.prototype.draw=function(a,c){""!=this.family?this.drawFamilyAux(this.ctx,a,c):0<this.evaluator.eval(this.drawif)&&
(this.update(),this.drawAux(this.ctx,a,c))};a.Graphic.prototype.drawTrace=function(a,c){""!=this.family?this.drawFamilyAux(this.traceCtx,a,c):0<this.evaluator.eval(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,c))};a.Graphic.prototype.rotate=function(a,g,b){d=Math.cos(b);c=Math.sin(b);return{x:a*d-g*c,y:a*c+g*d}};a.Graphic.prototype.dashStyle=function(){m=this.ctx;"dot"===this.lineDash?(m.lineCap="butt",m.setLineDash([m.lineWidth,m.lineWidth])):"dash"===this.lineDash?(m.lineCap="butt",
m.setLineDash([4*m.lineWidth,3*m.lineWidth])):"dash_dot"===this.lineDash?(m.lineCap="butt",m.setLineDash([4*m.lineWidth,2*m.lineWidth,m.lineWidth,2*m.lineWidth])):m.setLineDash([])};a.Graphic.prototype.drawText=function(a,c,b,l,d,f,k,x,m,v,y){a.textNode=c;if("rtfNode"===c.type)a.fillStyle=d.getColor(),a.strokeStyle=d.getColor(),a.textBaseline="alphabetic",a.textNode.pos={x:b,y:l},c.update(a,b,l,m,v,k,y,d.getColor());else for("simpleText"===c.type&&(c=c.toString(m,v).split("\\n")),h=this.evaluator,
a.fillStyle=d.getColor(),a.font=f,a.textAlign=k,a.textBaseline=x,e=1.2*this.fontSize||0,d=0,f=c.length;d<f;d++)n=c[d],this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=4,a.lineJoin="round",a.miterLimit=2,a.strokeText(n,b,l+e*d)),a.fillText(n,b,l+e*d)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d;a.SimpleText=function(a,k){this.text=k=k.replace("&#x2013","\u2013").replace(/&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";h="'";n=f=0;for(e=-1;f<k.length;)m=k.charAt(f),d=k.charAt(f-1),"["===m&&"\\"===d?(this.textElements.push(k.substring(n,f-1)+"["),this.textElementsMacros.push("'"+k.substring(n,f-1)+"['"),n=f+1):"]"===m&&"\\"===d?(this.textElements.push(k.substring(n,
f-1)+"]"),this.textElementsMacros.push("'"+k.substring(n,f-1)+"]'"),n=f+1):"["===m&&-1===e?(this.textElements.push(k.substring(n,f)),this.textElementsMacros.push("'"+k.substring(n,f)+"'"),n=f,e++):"["===m?e++:"]"===m&&0===e?(this.textElements.push(this.evaluator.parser.parse(k.substring(n,f+1))),this.textElementsMacros.push("["+k.substring(n,f+1)+"]"),n=f+1,e--):("]"==k.charAt(f)&&(e=0>e?e:e-1),h+=k.charAt(f)),f++;this.textElements.push(k.substring(n,f));this.textElementsMacros.push("'"+k.substring(n,
f)+"'")};a.SimpleText.prototype.toString=function(c,d){h="";for(var g=0,b=this.textElements.length;g<b;g++)"string"===typeof this.textElements[g]?h+=this.textElements[g]:(k=this.evaluator.eval(this.textElements[g])[0][0],""!==k&&("string"===typeof k?h+=k:Infinity==k?h+="Infinity":-Infinity==k?h+="-Infinity":isNaN(k)||"NaN"==k?h+="NaN":(k=parseFloat(k),k=d?k.toFixed(c):a.removeNeedlessDecimals(k.toFixed(c)),h+=k.toString().replace(".",this.parent.decimal_symbol))));return h};return a}(descartesJS||
{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r,g,b,l,w,q,u,x,p,v,y,A,C,I,G,K,E,z,F;a.Equation=function(b,c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,c);this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();l=new a.R2;w=new a.R2;q=new a.R2;p=new a.R2;u=new a.R2;this.cInd=0};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=
this.expresion.childs[0],c=this.expresion.childs[1];"identifier"!=b.type||"y"!=b.value||c.contains("y")?"identifier"!=c.type||"y"!=c.value||b.contains("y")?"identifier"!=b.type||"x"!=b.value||c.contains("x")?"identifier"!=c.type||"x"!=c.value||b.contains("x")||(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!1,this.drawAux=this.drawAuxFun)}this.newt=
new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))};a.Equation.prototype.drawFamilyAux=function(a,b,c){k=this.evaluator;this.getFamilyValues();tempParam=k.getVariable(this.family);if(0<=this.fSteps)for(var l=0,g=this.fSteps;l<=g;l++)k.setVariable(this.family,this.familyInf+l*this.family_sep),this.update(),
this.drawAux(a,b,c);k.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};var L,N,M,B,D,J,H;a.Equation.prototype.drawAux=function(P,O,Q){if(!(0>=this.evaluator.eval(this.drawif))){this.cInd=0;k=this.evaluator;f=k.parser;n=this.space;e=k.eval(this.width);P.strokeStyle=this.color.getColor();P.lineWidth=e;m=f.getVariable("x");d=f.getVariable("y");c=n.w+24;r=n.h+24;g=c/9;3>g&&(g=3);b=r/7;3>b&&(b=3);0==this.cInd?(h=[],this.cInd++):
this.cInd=(this.cInd+1)%1E7;l.set(0,0);w.set(0,0);q.set(0,0);J=.25;H=8;this.abs_coord||(J/=n.scale,H/=n.scale);P.beginPath();for(F=parseInt(b/2);F<r;F+=b)for(z=parseInt(g/2);z<c;z+=g){if(this.abs_coord){p.set(z,F);x=this.newt.findZero(p,J);if(null==x)continue;k.setVariable("x",x.x);k.setVariable("y",x.y);u.set(x.x,x.y)}else{p.set(n.getRelativeX(z),n.getRelativeY(F));x=this.newt.findZero(p,J);if(null==x)continue;k.setVariable("x",x.x);k.setVariable("y",x.y);u.set(n.getAbsoluteX(x.x),n.getAbsoluteY(x.y))}v=
u.ix();y=u.iy();if(-12<=v&&v<c+24&&-12<=y&&y<r+24){if(h[v+12+(y+12)*n.w]===this.cInd)continue;h[v+12+(y+12)*n.w]=this.cInd}a.rangeOK&&(P.moveTo(v,y),P.lineTo(v,y));l.x=x.x;l.y=x.y;w.x=x.x;w.y=x.y;A=this.newt.getUnitNormal();if(0!=A.x||0!=A.y)for(A.rotL90(),q.x=A.x,q.y=A.y,I=C=0,G=!1;2>I;)if(G&&(q.x=-A.x,q.y=-A.y,x.x=l.x,x.y=l.y,w.x=x.x,w.y=x.y,this.abs_coord?u.set(x.x,x.y):u.set(n.getAbsoluteX(x.x),n.getAbsoluteY(x.y)),v=u.ix(),y=u.iy(),G=!1,C=0),x.x+=H*q.x,x.y+=H*q.y,x=this.newt.findZero(x,J),null!=
x){k.setVariable("x",x.x);k.setVariable("y",x.y);q.x=x.x-w.x;q.y=x.y-w.y;q.normalize();if(0==q.x&&0==q.y)break;w.x=x.x;w.y=x.y;this.abs_coord?u.set(x.x,x.y):u.set(n.getAbsoluteX(x.x),n.getAbsoluteY(x.y));K=parseInt(u.ix());E=parseInt(u.iy());if(K!=v||E!=y)if(L=v,N=y,v=K,y=E,-12<=v&&v<c+24&&-12<=y&&y<r+24){C=0;M=h[v+12+(y+12)*n.w];h[v+12+(y+12)*n.w]=this.cInd;for(O=1;8>O;O++)B=L+Math.round((v-L)*O/8),D=N+Math.round((y-N)*O/8),0<=B&&B<c&&0<=D&&D<r&&(h[B+12+(D+12)*n.w]=this.cInd);a.rangeOK&&(P.moveTo(L,
N),P.lineTo(v,y));if(M===this.cInd)break}else G=!0,I++;else 4<++C&&(G=!0,I++)}}P.stroke()}};a.Equation.prototype.X=function(a,b,c){c||(b=this.space.w/2+this.space.Ox+this.space.scale*b);b<-a&&(b=-a);b>this.space.w+a&&(b=this.space.w+a);return b};a.Equation.prototype.Y=function(a,b,c){c||(b=this.space.h/2+this.space.Oy-this.space.scale*b);b<-a&&(b=-a);b>this.space.h+a&&(b=this.space.h+a);return b};a.Equation.prototype.XX=function(a,b,c){return Math.round(this.X(a,b,c))};a.Equation.prototype.YY=function(a,
b,c){return Math.round(this.Y(a,b,c))};a.Equation.prototype.extrapolate=function(b,c,l,g,d,f){for(var e=this.evaluator.getVariable(c),h=f/2,k=0,u,q,x,m,n,p;1E-15<Math.abs(h);){u=this.evaluator.getVariable(c);q=this.evaluator.getVariable(c)+h;this.evaluator.setVariable(c,q);x=!0;try{m=d,d=this.evaluator.eval(this.funExpr),this.evaluator.setVariable(l,d),0<this.evaluator.eval(b)?(n=new a.R2(Math.min(m,d),Math.max(m,d)),p=0,p=0<f?this.Singularity(Math.abs(h),c,g,u,m,q,d,n):this.Singularity(Math.abs(h),
c,g,q,d,u,m,n),0<p&&(x=!1)):x=!1}catch(X){x=!1}x?k+=h:this.evaluator.setVariable(c,u);h/=2}this.evaluator.setVariable(c,e);return new a.R2(k/Math.abs(f),d)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,l,g,d,f){g=this.evaluator.getVariable(c);for(var e=f/2,h=0,k=d,u;1E-15<Math.abs(e);){this.evaluator.setVariable(c,this.evaluator.getVariable(c)+e);u=!0;if(0<this.evaluator.eval(b))try{k=this.evaluator.eval(this.funExpr),this.evaluator.setVariable(l,k),0>=this.evaluator.eval(b)&&(u=!1)}catch(V){u=
!1}else u=!1;u?h+=e:this.evaluator.setVariable(c,this.evaluator.getVariable(c)-e);e/=2}if(0==h)for(e=f/2,h=f,k=d;1E-15<Math.abs(e);){this.evaluator.setVariable(c,this.evaluator.getVariable(c)-e);u=!0;if(0<this.evaluator.eval(b))try{k=this.evaluator.eval(this.funExpr)}catch(V){u=!1}else u=!1;u?h+=-e:this.evaluator.setVariable(c,this.evaluator.getVariable(c)+e);e/=2}this.evaluator.setVariable(c,g);return new a.R2(h/Math.abs(f),k)};a.Equation.prototype.Singularity=function(a,b,c,l,g,d,f,e){if(isNaN(f)||
isNaN(g)||isNaN(e.y)||isNaN(e.x)||l>=d)return 2;var h=this.evaluator.getVariable(b),k=0;try{if(1E-15>Math.abs(d-l)||1E-12>Math.abs(d-l)&&Math.abs(f-g)>Math.abs(a))return this.evaluator.setVariable(b,h),1;var u=(l+d)/2;this.evaluator.setVariable(b,u);var q=NaN;try{q=this.evaluator.eval(this.funExpr)}catch(W){return 2}if(isNaN(q))return 5;if(Math.abs(f-g)>a){this.evaluator.setVariable(b,l-1E-12);var x=this.evaluator.eval(this.funExpr);x=(g-x)/1E-12;this.evaluator.setVariable(b,d+1E-12);var m=(this.evaluator.eval(this.funExpr)-
f)/1E-12;if((10>Math.abs(m)||10>Math.abs(x))&&(0<=m&&0<=x||0>=m&&0>=x)&&4*Math.abs(m)<Math.abs((f-g)/(d-l)))return this.evaluator.setVariable(b,h),2}if(isNaN(e.x)||isNaN(e.y)||isNaN(q))return 2;if(!(e.x<=q&&q<=e.y)){this.evaluator.setVariable(b,u);e.x=Math.min(g,q);e.y=Math.max(g,q);var n=this.Singularity(a/2,b,c,l,g,u,q,e);this.evaluator.setVariable(b,d);e.x=Math.min(f,q);e.y=Math.max(f,q);var p=this.Singularity(a/2,b,c,u,q,d,f,e);k=Math.max(n,p)}}catch(W){k=1}this.evaluator.setVariable(b,h);return k};
a.Equation.prototype.drawAuxFun=function(b,c,l){m=this.evaluator.parser.getVariable("x");d=this.evaluator.parser.getVariable("y");a.rangeOK=1;c="x";var g="y";this.of_y&&(c="y",g="x");var f=this.drawif,e=this.evaluator.eval(this.width),h=!1,k=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),u=this.of_y?k.ix():k.iy(),q=0,x=0,n=0,p=0,r=1/this.space.scale;k=r*(this.of_y?-this.space.h+k.y:-k.x);var w=0;this.abs_coord&&(k=0,r=1);for(var A,y,v,G,z,C,K,H,O,D=this.of_y?this.space.h+2:this.space.w+
2;n<=D;){A=!0;y=0;this.evaluator.setVariable(c,k);try{v=this.evaluator.eval(this.funExpr),isNaN(v)||(this.evaluator.setVariable(g,v),0<this.evaluator.eval(this.drawif)&&a.rangeOK?(h?(G=Math.min(w,v),z=Math.max(w,v),C=new a.R2(G,z),y=this.Singularity(r,c,0,k-r,w,k,v,C),0===y?(w<=v?(w=C.x,v=C.y):(v=C.x,w=C.y),K=parseInt(this.of_y?this.XX(e,w,this.abs_coord):this.YY(e,w,this.abs_coord)),q=this.abs_coord?Math.round(v):parseInt(this.of_y?this.XX(e,v,this.abs_coord):this.YY(e,v,this.abs_coord)),this.fillM&&
q>u&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(u+1,this.space.h-n+.5),b.lineTo(q,this.space.h-n+.5)):(b.moveTo(n+.5,u+1),b.lineTo(n+.5,q)),b.stroke()),this.fillP&&q<u&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(u-1,this.space.h-n+.5),b.lineTo(q,this.space.h-n+.5)):(b.moveTo(n+.5,u-1),b.lineTo(n+.5,q)),b.stroke()),b.lineWidth=e,b.strokeStyle=l.getColor(),b.beginPath(),this.of_y?(b.moveTo(K+.5,this.space.h-p),b.lineTo(q+
.5,this.space.h-n)):(b.moveTo(p+.5,K),b.lineTo(n+.5,q)),b.stroke()):1===y?(this.evaluator.setVariable(c,k-r),H=this.extrapolate(f,c,g,0,w,r),q=this.of_y?this.XX(e,H.y,this.abs_coord):this.YY(e,H.y,this.abs_coord),b.lineWidth=e,b.strokeStyle=l.getColor(),b.beginPath(),this.of_y?(b.moveTo(x+.5,this.space.h-p),b.lineTo(q+.5,this.space.h-p+Math.round(H.x))):(b.moveTo(p+.5,x),b.lineTo(p+Math.round(H.x)+.5,q)),this.evaluator.setVariable(c,k),O=this.extrapolate(f,c,g,0,v,-r),x=this.of_y?this.XX(e,O.y,this.abs_coord):
this.YY(e,O.y,this.abs_coord),q=this.of_y?this.XX(e,v,this.abs_coord):this.YY(e,v,this.abs_coord),b.lineWidth=e,b.strokeStyle=l.getColor(),b.beginPath(),this.of_y?(b.moveTo(x+.5,this.space.h-n),b.lineTo(q+.5,this.space.h-n)):(b.moveTo(n+.5,x),b.lineTo(n+.5,q)),b.stroke()):2===y&&(q=this.of_y?this.XX(e,v,this.abs_coord):this.YY(e,v,this.abs_coord),b.lineWidth=e,b.strokeStyle=l.getColor(),b.beginPath(),this.of_y?(b.moveTo(x+.5,this.space.h-n),b.lineTo(q+.5,this.space.h-n)):(b.moveTo(n+.5,x),b.lineTo(n+
.5,q)))):(O=this.extrapolateOnSingularity(f,c,g,0,v,-r),x=this.of_y?this.XX(e,O.y,this.abs_coord):this.YY(e,O.y,this.abs_coord),q=this.of_y?this.XX(e,v,this.abs_coord):this.YY(e,v,this.abs_coord),b.lineWidth=e,b.strokeStyle=l.getColor(),b.beginPath(),this.of_y?(b.moveTo(x,this.space.h-(n+Math.round(O.x))+.5),b.lineTo(q,this.space.h-n+.5)):(b.moveTo(n+Math.round(O.x),x),b.lineTo(n,q)),b.stroke()),w=v):A=!1)}catch(Y){A=!1}h&&!A&&(this.evaluator.setVariable(c,k-r),this.evaluator.setVariable(g,w),H=this.extrapolate(f,
c,g,0,w,r),q=parseInt(this.of_y?this.XX(e,H.y,this.abs_coord):this.YY(e,H.y,this.abs_coord)),0<this.evaluator.eval(this.drawif)&&a.rangeOK&&(b.lineWidth=e,b.strokeStyle=l.getColor(),b.beginPath(),this.of_y?(b.moveTo(x,this.space.h-(p+Math.round(H.x))+.5),b.lineTo(q,this.space.h-(p+Math.round(H.x))+.5)):(b.moveTo(p+Math.round(H.x)+.5,x),b.lineTo(p+Math.round(H.x)+.5,q)),b.stroke()),this.evaluator.setVariable(c,k));h=A;k+=r;x=q;p=n++}this.evaluator.parser.setVariable("x",m);this.evaluator.parser.setVariable("y",
d)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;oncontextmenu=function(a){return!1};a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,k,f,n,e,m,d,c,r;a.Curve=function(c,b){this.parameter="t";this.parameter_interval=c.evaluator.parser.parse("[0,1]");this.parameter_steps=c.evaluator.parser.parse("8");this.width=c.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,c,b);(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);a.Curve.prototype.update=function(){k=this.evaluator;f=k.eval(this.parameter_interval);
this.paraInf=f[0][0];this.paraSup=f[0][1];this.pSteps=k.eval(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Curve.prototype.drawAux=function(g,b,l){k=this.evaluator;n=this.space;e=h(k.eval(this.width));g.lineWidth=0<e?e:1E-6;g.lineCap="round";g.lineJoin="round";g.strokeStyle=
l.getColor();m=k.getVariable(this.parameter);g.beginPath();k.setVariable(this.parameter,this.paraInf);d=k.eval(this.expresion);this.exprX=h(this.abs_coord?d[0][0]:n.getAbsoluteX(d[0][0]));this.exprY=h(this.abs_coord?d[0][1]:n.getAbsoluteY(d[0][1]));this.rotateExp&&(c=a.degToRad(k.eval(this.rotateExp)),r=this.rotate(d[0][0],d[0][1],c),this.exprX=h(this.abs_coord?r.x:n.getAbsoluteX(r.x)),this.exprY=h(this.abs_coord?r.y:n.getAbsoluteY(r.y)));g.moveTo(this.exprX+.5,this.exprY+.5);for(l=1;l<=this.pSteps;l++)k.setVariable(this.parameter,
this.paraInf+l*this.paraSep),d=k.eval(this.expresion),this.rotateExp&&(r=this.rotate(d[0][0],d[0][1],c),d[0][0]=r.x,d[0][1]=r.y),this.exprX=h(this.abs_coord?d[0][0]:n.getAbsoluteX(d[0][0])),this.exprY=h(this.abs_coord?d[0][1]:n.getAbsoluteY(d[0][1])),!isNaN(this.exprX)&&!isNaN(this.exprY)&&-1E6<this.exprX&&1E6>this.exprX&&-1E6<this.exprY&&1E6>this.exprY&&g.lineTo(this.exprX+.5,this.exprY+.5);this.fill&&(g.fillStyle=b.getColor(),g.fill("evenodd"));this.dashStyle();g.stroke();g.setLineDash([]);k.setVariable(this.parameter,
m)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.oncontextmenu=function(a){return!1};a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=2*Math.PI,k=Math.round,f,n,e,m,d,c,r,g,b,l,w;a.Sequence=function(b,c){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,c);(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField()};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){f=this.evaluator;e=f.eval(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1];this.rotateExp&&
(m=a.degToRad(f.eval(this.rotateExp)),d=this.rotate(e[0][0],e[0][1],m),this.exprX=d.x,this.exprY=d.y);g=f.eval(this.range);this.rangeInf=g[0][0];this.rangeMax=g[0][1]};a.Sequence.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Sequence.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Sequence.prototype.drawAux=function(a,g){f=this.evaluator;n=this.space;l=b=Math.ceil(f.eval(this.size)-.4);a.fillStyle=g.getColor();a.beginPath();this.rangeInf>
this.rangeMax&&(w=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=w);g=f.getVariable("n");for(var d=this.rangeInf,u=this.rangeMax;d<=u;d++)f.setVariable("n",d),e=f.eval(this.expresion),this.exprX=e[0][0],this.exprY=e[0][1],c=k(this.abs_coord?this.exprX:n.getAbsoluteX(this.exprX)),r=k(this.abs_coord?this.exprY:n.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(c,r,b,0,h,!0),a.fill();a.fill();this.text!=[""]&&(this.fontSize=Math.max(5,f.eval(this.font_size)),this.font=this.font_style+" "+this.fontSize+
"px "+this.font_family,this.uber.drawText.call(this,a,this.text,c+l,r-l,this.color,this.font,"start","alphabetic",f.eval(this.decimals),this.fixed,!0));f.setVariable("n",g)};a.Sequence.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;oncontextmenu=function(a){return!1};a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parent.update())};this.parent.editableRegion.textFields.push(a)};
return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=2*Math.PI,k=Math.round,f,n,e,m,d,c,r,g;a.Point=function(b,c){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c);this.text=new a.TextObject(this,this.text)};a.extend(a.Point,a.Graphic);a.Point.prototype.update=function(){f=this.evaluator;e=f.eval(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1];this.rotateExp&&(m=a.degToRad(f.eval(this.rotateExp)),d=this.rotate(e[0][0],e[0][1],m),this.exprX=d.x,this.exprY=d.y)};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,l){f=this.evaluator;n=this.space;g=k(f.eval(this.size));a.fillStyle=l.getColor();c=k(this.abs_coord?this.exprX:n.getAbsoluteX(this.exprX));r=k(this.abs_coord?this.exprY:n.getAbsoluteY(this.exprY));a.beginPath();a.arc(c,r,g,0,h,!0);a.fill();this.text.hasContent&&this.text.draw(a,l,c,r)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,k=2*Math.PI,f,n,e,m,d,c,r,g,b,l,w,q,u;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);this.text=new a.TextObject(this,this.text)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){f=this.evaluator;e=f.eval(this.expresion);this.endPoints=[];for(var b=0,c=e.length;b<c;b++)this.endPoints[b]={x:e[b][0],y:e[b][1]};if(this.rotateExp)for(m=a.degToRad(f.eval(this.rotateExp)),
b=0,c=this.endPoints.length;b<c;b++)this.endPoints[b]=this.rotate(this.endPoints[b].x,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,e,m){f=this.evaluator;n=this.space;d=h(f.eval(this.width));a.lineWidth=0<d?d:1E-6;g=f.eval(this.size);0>g&&(g=0);a.fillStyle=e.getColor();a.strokeStyle=m.getColor();a.lineCap=
"round";b=0==a.lineWidth%2?0:.5;this.abs_coord?(l=h(this.endPoints[0].x),w=h(this.endPoints[0].y),q=h(this.endPoints[1].x),u=h(this.endPoints[1].y)):(l=h(n.getAbsoluteX(this.endPoints[0].x)),w=h(n.getAbsoluteY(this.endPoints[0].y)),q=h(n.getAbsoluteX(this.endPoints[1].x)),u=h(n.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(l+b,w+b);a.lineTo(q+b,u+b);this.dashStyle();a.stroke();0<g&&(a.beginPath(),a.arc(l,w,g,0,k,!0),a.arc(q,u,g,0,k,!0),a.fill());a.setLineDash([]);this.text.hasContent&&
(c=parseInt((l+q)/2)-3,r=parseInt((w+u)/2)+3,this.text.draw(a,m,c,r))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,k=Math.round,f,n,e,m,d,c,r,g,b,l,w,q,u,x,p;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);this.text=new a.TextObject(this,this.text)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){f=this.evaluator;n=f.eval(this.expresion);this.endPoints=[];for(var b=0,c=n.length;b<
c;b++)this.endPoints[b]={x:n[b][0],y:n[b][1]};if(this.rotateExp)for(e=a.degToRad(f.eval(this.rotateExp)),b=0,c=this.endPoints.length;b<c;b++)this.endPoints[b]=this.rotate(this.endPoints[b].x,this.endPoints[b].y,e)};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(e,n,A){f=this.evaluator;m=this.space;r=f.eval(this.width);0>r&&(r=0);g=Math.ceil(r/
2);b=m.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);l=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);e.fillStyle=n.getColor();e.strokeStyle=A.getColor();e.lineWidth=2;this.abs_coord?(w=k(this.endPoints[0].x),q=k(this.endPoints[0].y),u=k(this.endPoints[1].x),x=k(this.endPoints[1].y)):(w=k(m.getAbsoluteX(this.endPoints[0].x)),q=k(m.getAbsoluteY(this.endPoints[0].y)),u=k(m.getAbsoluteX(this.endPoints[1].x)),
x=k(m.getAbsoluteY(this.endPoints[1].y)));p=f.eval(this.spear);0>p&&(p=0);e.save();e.translate(w,q,l);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?e.rotate(this.angle):e.rotate(-this.angle):(l*=b,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?e.rotate(-this.angle):e.rotate(this.angle));e.beginPath();e.moveTo(-g,h(-g));e.lineTo(h(l-p-r),h(-g));e.lineTo(h(l-2*p),h(-p-g));e.lineTo(h(l),0);e.lineTo(h(l-2*p),h(p+g));e.lineTo(h(l-p-r),h(g));e.lineTo(-g,h(g));
e.closePath();e.stroke();e.fill();e.restore();this.text.hasContent&&(d=parseInt((w+u)/2)-3,c=parseInt((q+x)/2)+3,this.text.draw(e,A,d,c))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,k,f,n,e,m,d,c,r;a.Polygon=function(c,b){this.width=c.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,c,b);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){k=this.evaluator;n=k.eval(this.expresion);for(var c=0,b=n.length;c<b;c++)this.endPoints[c]={x:n[c][0],y:n[c][1]};if(this.rotateExp)for(e=a.degToRad(k.eval(this.rotateExp)),c=0,b=this.endPoints.length;c<b;c++)this.endPoints[c]=this.rotate(this.endPoints[c].x,
this.endPoints[c].y,e)};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,l){k=this.evaluator;f=this.space;m=h(k.eval(this.width));a.lineWidth=0<m?m:1E-6;a.strokeStyle=l.getColor();a.lineCap=a.lineJoin="round";d=0<m?.5:0;c=h(this.abs_coord?this.endPoints[0].x:f.getAbsoluteX(this.endPoints[0].x));r=h(this.abs_coord?this.endPoints[0].y:
f.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(c+d,r+d);l=1;for(var g=this.endPoints.length;l<g;l++)c=h(this.abs_coord?this.endPoints[l].x:f.getAbsoluteX(this.endPoints[l].x)),r=h(this.abs_coord?this.endPoints[l].y:f.getAbsoluteY(this.endPoints[l].y)),a.lineTo(c+d,r+d);this.fill&&(a.fillStyle=b.getColor(),a.fill());this.dashStyle();a.stroke();a.setLineDash([])};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,k=Math.min,f=Math.max,n=Math.abs,e,m,d,c,r,g,b,l,w,q,u,x;a.Rectangle=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";this.border_radius=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.endPoints=[]};a.extend(a.Rectangle,a.Graphic);a.Rectangle.prototype.update=function(){e=this.evaluator;expr=e.eval(this.expresion);this.exprX=expr[0][0];this.exprY=expr[0][1];this.w=150;this.h=100;this.rotateExp&&(d=a.degToRad(e.eval(this.rotateExp)),
c=this.rotate(expr[0][0],expr[0][1],d),this.exprX=c.x,this.exprY=c.y);4<=expr[0].length&&(this.w=expr[0][2],this.h=expr[0][3]);expr[1]&&2==expr[1].length&&(this.w=expr[1][0],this.h=expr[1][1]);this.w=f(0,this.w);this.h=f(0,this.h)};a.Rectangle.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Rectangle.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace,"trace")};a.Rectangle.prototype.drawAux=function(a,c,d,A){e=this.evaluator;m=this.space;r=
h(e.eval(this.width));a.lineWidth=0<r?r:1E-6;a.strokeStyle=d.getColor();a.lineCap="round";a.lineJoin="miter";g=0<r?.5:0;b=h(this.abs_coord?this.exprX:m.getAbsoluteX(this.exprX))+g;l=h(this.abs_coord?this.exprY:m.getAbsoluteY(this.exprY))+g;w=this.abs_coord?this.w:this.w*m.scale;q=this.abs_coord?this.h:-this.h*m.scale;u=k(f(0,e.eval(this.border_radius)),.5*n(w),.5*n(q));x=this.abs_coord?1:-1;a.beginPath();0!==u?(a.moveTo(b+u,l),a.lineTo(b+w-u,l),a.quadraticCurveTo(b+w,l,b+w,l+x*u),a.lineTo(b+w,l+q-
x*u),a.quadraticCurveTo(b+w,l+q,b+w-u,l+q),a.lineTo(b+u,l+q),a.quadraticCurveTo(b,l+q,b,l+q-x*u),a.lineTo(b,l+x*u),a.quadraticCurveTo(b,l,b+u,l),a.lineTo(b+u,l)):(a.moveTo(b,l),a.lineTo(b+w,l),a.lineTo(b+w,l+q),a.lineTo(b,l+q),a.lineTo(b,l));this.fill&&(a.fillStyle=c.getColor(),a.fill());this.dashStyle();a.stroke();a.setLineDash([])};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,k=Math.min,f=Math.max,n=Math.acos,e=Math.sqrt,m=Math.PI,d=m/2,c=2*m,r,g,b,l,w,q,u,x,p,v,y,A,C,I,G,K,E,z,F,L,N;a.Arc=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=b.evaluator.parser.parse("1");this.init="0";this.end="90";a.Graphic.call(this,b,c);this.init.match(/^_\(/)&&(this.initFlag=!0,this.init=this.init.substring(1));this.end.match(/^_\(/)&&(this.endFlag=
!0,this.end=this.end.substring(1));this.initExpr=b.evaluator.parser.parse(this.init);this.endExpr=b.evaluator.parser.parse(this.end);this.text=new a.TextObject(this,this.text)};a.extend(a.Arc,a.Graphic);a.Arc.prototype.update=function(){r=this.evaluator;g=r.eval(this.center);this.exprX=g[0][0];this.exprY=g[0][1];b=0;this.rotateExp&&(b=a.degToRad(r.eval(this.rotateExp)),l=Math.cos(b),w=Math.sin(b),q=this.exprX*l-this.exprY*w,u=this.exprX*w+this.exprY*l,this.exprX=q,this.exprY=u);var h=r.eval(this.initExpr),
z=r.eval(this.endExpr);/^(\(|\[)expr(\)|\])$/i.test(this.initExpr.type)&&/^(\(|\[)expr(\)|\])$/i.test(this.endExpr.type)?(x=h[0][0],p=h[0][1],v=z[0][0],y=z[0][1],this.vectors?this.abs_coord&&(p=-p,y=-y):this.abs_coord?(x-=this.exprX,p=-p+this.exprY,v-=this.exprX,y=-y+this.exprY):(x-=this.exprX,p-=this.exprY,v-=this.exprX,y-=this.exprY),A=0==x?0>p?3*d:d:n(1*x/e(x*x+p*p)),C=0==v?0>y?3*d:d:n(1*v/e(v*v+y*y)),A+=b,C+=b,0<x&&0<p&&this.abs_coord&&(A=c-A),0<x&&0>p&&!this.abs_coord&&(A=c-A),0>x&&0>p&&!this.abs_coord&&
(A=c-A),0>x&&0<p&&this.abs_coord&&(A=c-A),0<v&&0<y&&this.abs_coord&&(C=c-C),0<v&&0>y&&!this.abs_coord&&(C=c-C),0>v&&0>y&&!this.abs_coord&&(C=c-C),0>v&&0<y&&this.abs_coord&&(C=c-C),this.initFlag?(I=A,A=C,C=I):(I=k(A,C),G=f(A,C),A=I,C=G,C-A>m&&this.abs_coord&&(A=G,C=I),C-A<=m&&!this.abs_coord&&(A=G,C=I)),this.iniAng=A,this.endAng=C,this.drawPoints=!0):(this.iniAng=a.degToRad(h)+b,this.endAng=a.degToRad(z)+b,this.drawAngle=!0)};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};
a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(a,b,c){r=this.evaluator;K=this.space;F=r.eval(this.radius);0>F&&(F=0);N=h(r.eval(this.width));a.lineWidth=0<N?N:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.drawAngle?(this.abs_coord?(E=h(this.exprX),z=h(this.exprY)):(E=h(K.getAbsoluteX(this.exprX)),z=h(K.getAbsoluteY(this.exprY)),F*=K.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&
(L=this.iniAng,this.iniAng=this.endAng,this.endAng=L)):this.drawPoints&&(this.abs_coord?(E=h(this.exprX),z=h(this.exprY)):(E=h(K.getAbsoluteX(this.exprX)),z=h(K.getAbsoluteY(this.exprY)),F*=K.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(E,z),a.arc(E,z,F,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(E,z,F,this.iniAng,this.endAng,void 0);this.dashStyle();a.stroke();this.text.hasContent&&this.text.draw(a,this.color,
E,z)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m;a.Text=function(d,c){this.width=d.evaluator.parser.parse("0");a.Graphic.call(this,d,c);this.align||(this.align="left");this.anchor||(this.anchor="top_left");this.text=new a.TextObject(this,this.text)};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){h=this.evaluator;k=h.eval(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];this.rotateExp&&(f=a.degToRad(h.eval(this.rotateExp)),n=this.rotate(k[0][0],k[0][1],f),this.exprX=
n.x,this.exprY=n.y)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace)};a.Text.prototype.drawAux=function(a,c){this.abs_coord?(e=parseInt(this.exprX),m=parseInt(this.exprY)):(e=parseInt(this.space.getAbsoluteX(this.exprX)),m=parseInt(this.space.getAbsoluteY(this.exprY)));this.text.draw(a,c,e,m)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,k,f,n,e,m,d,c,r,g,b,l,w,q;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.scaleX=this.scaleY=1;this.ratio=b.ratio;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){k=this.evaluator;f=k.eval(this.expresion);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(n=a.degToRad(k.eval(this.rotateExp)),e=this.rotate(f[0][0],f[0][1],n),
this.exprX=e.x,this.exprY=e.y);4<=f[0].length&&(this.centered=!0,this.scaleX=f[0][2],this.scaleY=f[0][3]);f[1]&&2==f[1].length&&(this.centered=!0,this.scaleX=f[1][0],this.scaleY=f[1][1]);0==this.scaleX&&(this.scaleX=1E-5);0==this.scaleY&&(this.scaleY=1E-5);var b=this;if((m=k.eval(this.file))||""==m)this.img=this.parent.getImage(m),this.img.addEventListener("load",function(a){b.space.update(!0)})};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(e){k=this.evaluator;d=this.space;this.img&&this.img.ready&&this.img.complete&&(w=this.img.width,q=this.img.height,this.img.canvas&&(w=h(w/this.ratio),q=h(q/this.ratio)),c=this.centered?0:h(w/2),r=this.centered?0:h(q/2),g=h(this.abs_coord?this.exprX:d.getAbsoluteX(this.exprX)),b=h(this.abs_coord?this.exprY:d.getAbsoluteY(this.exprY)),l=a.degToRad(-k.eval(this.inirot)),e.save(),e.translate(g+c,b+r),e.rotate(l),this.opacity&&(e.globalAlpha=k.eval(this.opacity)),e.scale(this.scaleX,
this.scaleY),e.drawImage(this.img,-w/2,-q/2,w,q),e.restore())};return a}(descartesJS||{});
descartesJS=function(a){function h(a,b,l){c=4*(b+l*a.width);return{r:a.data[c],g:a.data[c+1],b:a.data[c+2],a:a.data[c+3]}}if(a.loadLib)return a;var k,f,n,e,m,d,c,r;a.Fill=function(c,b){a.Graphic.call(this,c,b)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){k=this.evaluator.eval(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,
this.trace)};a.Fill.prototype.drawAux=function(a,b){b.getColor();imageData=a.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(f=parseInt(this.exprX),n=parseInt(this.exprY)):(f=parseInt(this.space.getAbsoluteX(this.exprX)),n=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>f||0>n||f>=this.space.w||n>=this.space.h)){e=[[f,n]];d=h(imageData,f,n);for(r=0;0<e.length;){r++;m=e.pop();f=m[0];n=m[1];var l=h(imageData,f,n);if(d.r===l.r&&d.g===l.g&&d.b===l.b&&d.a===l.a){l=imageData;var g=b;c=
4*(f+n*l.width);l.data[c+0]=g.r;l.data[c+1]=g.g;l.data[c+2]=g.b;l.data[c+3]=255*g.a;0<f&&e.push([f-1,n]);f<imageData.width-1&&e.push([f+1,n]);e.push([f,n-1]);e.push([f,n+1])}if(r>=this.space.w*this.space.h*3)break}a.putImageData(imageData,0,0)}};return a}(descartesJS||{});
descartesJS=function(a,h){if(a.loadLib)return a;var k=new String("-text-image-point-polygon-arc-segment-arrow-macro-curve-equation-sequence-rectangle-fill-"),f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,n;a.Macro=function(e,n){this.hasExpresion=!1;this.inirot=e.evaluator.parser.parse("0");this.inipos=e.evaluator.parser.parse("(0,0)");a.Graphic.call(this,e,n);for(var d in n)"expresion"==d&&(this.hasExpresion=!0),n.hasOwnProperty(d)&&(this[d]=n[d]);this.graphics=[];e=e.lessonParser;var c=new a.Tokenizer;
if(this.hasExpresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);n=this.evaluator.eval(this.expresion);if(n)var r=(r=document.getElementById(n))&&"descartes/macro"==r.type?r.text:a.openExternalFile(n);if(r){var g=r.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,
"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&").replace(/\r/g,"").split("\n");r=[];n=0;for(d=g.length;n<d;n++)if(g[n].trim()){var b=g[n].indexOf("=");if(-1!==b){b=e.split(g[n]);for(var l=0,m=b.length;l<m;l++)if(b[l]&&1<b.length&&("id"===h[b[l][0]]||"type"===h[b[l][0]])){r.push(b);break}}}n=0;for(d=r.length;n<d;n++)for(m=(l=
r[n]||[],l[0])&&"id"===l[0][0],g=0,b=l.length;g<b;g++){var q=l[g][0].indexOf(".");-1===q||m?q=h[l[g][0]]:(q=h[l[g][0].substring(q+1)],l[g][0]=this.name+"."+l[g][0]);if(!("font"===q||"font_family"===q||("fill"===q||"color"===q||"border"===q||"arrow"===q)&&"("!==l[g][1].charAt(0)||"file"===q&&l[g][1].match(f)||"id"!==q&&void 0!==h[l[g][1]])||"radius"===q)if("text"==q)if(l[g][1].match(/\{\\rtf1/)){q=l[g][1];var u=this;var x=function(b,l){l=c.tokenize(l.replace(/&squot;/g,"'"));for(var g=0,d=l.length;g<
d;g++)"identifier"!=l[g].type||a.reservedIds.match("-"+l[g].value+"-")||(l[g].value=u.name+"."+l[g].value);return(b.match(/^\\expr/)?"\\expr ":"\\decimals ")+c.flatTokens(l)};q=q.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,x);q=q.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,x);l[g][1]=q}else{x=e.parseText(l[g][1]).textElementsMacros;for(var p=0,v=x.length;p<v;p++){q=c.tokenize(x[p].replace(/&squot;/g,"'"));for(var y=0,A=q.length;y<A;y++)"identifier"!==
q[y].type||a.reservedIds.match("-"+q[y].value+"-")||(q[y].value=this.name+"."+q[y].value);q=c.flatTokens(q).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");x[p]=q.substring(1,q.length-1)}l[g][1]=x.join("")}else{x=l[g][1].replace(/&squot;/g,"'").split(";");p=0;for(v=x.length;p<v;p++){q=c.tokenize(x[p].replace(/\\n/g,";"));y=0;for(A=q.length;y<A;y++)"identifier"!==q[y].type||a.reservedIds.match("-"+q[y].value+"-")||(q[y].value=this.name+"."+q[y].value);x[p]=c.flatTokens(q)}l[g][1]=
x.join(";")}}n=0;for(d=r.length;n<d;n++)if(r[n][0]){l="";m=!1;g=0;for(b=r[n].length;g<b;g++)"type"===h[r[n][g][0]]&&k.match("-"+h[r[n][g][1]]+"-")&&(m=!0),l=l+r[n][g][0]+"='"+r[n][g][1]+"' ";r[n]=l+(m?" space='"+this.spaceID+"'":"");m?this.graphics.push(e.parseGraphic(r[n],this.abs_coord,this.background,this.inirot)):e.parseAuxiliar(r[n])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){n=this.evaluator.eval(this.inipos);this.iniPosX=n[0][0];this.iniPosY=n[0][1]};a.Macro.prototype.drawAux=
function(a){for(var e=0,d=this.graphics.length;e<d;e++)this.graphics[e]&&(a.save(),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.restore())};return a}(descartesJS||{},babel);
descartesJS=function(a){if(a.loadLib)return a;var h=Math.sqrt,k=Math.sin,f=Math.cos,n,e,m,d,c,r,g,b,l,w,q,u,x,p,v;a.norm3D=function(a){return h(a.x*a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(b){n=a.norm3D(b);if(0===n)return{x:0,y:0,z:0};if(1===n)return{x:b.x,y:b.y,z:b.z};n=1/n;return{x:b.x*n,y:b.y*n,z:b.z*n}};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,l){this.x=a||0;this.y=b||0;this.z=c||0;this.w=l||0;this.adjustDec()};a.Vector4D.prototype.adjustDec=function(){this.x=parseInt(1E9*this.x)/1E9;this.y=parseInt(1E9*this.y)/1E9;this.z=parseInt(1E9*this.z)/1E9};a.Matrix4x4=function(a,
b,c,l,g,d,e,f,h,k,q,u,n,x,r,m){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=l||0;this.a10=g||0;this.a11=d||0;this.a12=e||0;this.a13=f||0;this.a20=h||0;this.a21=k||0;this.a22=q||0;this.a23=u||0;this.a30=n||0;this.a31=x||0;this.a32=r||0;this.a33=m||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(c){e=k(c);m=f(c);b=this.a10;l=this.a11;w=this.a12;q=this.a13;u=this.a20;x=this.a21;p=this.a22;v=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,b*m+u*e,l*m+x*e,w*m+p*e,q*m+v*e,b*-e+u*m,l*-e+x*m,w*-e+p*m,q*-e+v*m,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){e=k(b);m=f(b);d=this.a00;c=this.a01;r=this.a02;
g=this.a03;u=this.a20;x=this.a21;p=this.a22;v=this.a23;return new a.Matrix4x4(d*m+u*-e,c*m+x*-e,r*m+p*-e,g*m+v*-e,this.a10,this.a11,this.a12,this.a13,d*e+u*m,c*e+x*m,r*e+p*m,g*e+v*m,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(h){e=k(h);m=f(h);d=this.a00;c=this.a01;r=this.a02;g=this.a03;b=this.a10;l=this.a11;w=this.a12;q=this.a13;return new a.Matrix4x4(d*m+b*e,c*m+l*e,r*m+w*e,g*m+q*e,d*-e+b*m,c*-e+l*m,r*-e+w*m,g*-e+q*m,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,
this.a32,this.a33)};return a}(descartesJS||{});
descartesJS=function(a){function h(a){a.textNode=null;0!==parseInt(this.size)&&(a.lineWidth=1,a.fillStyle=this.backColor,a.strokeStyle=this.frontColor,a.beginPath(),a.arc(this.projVert[0].x,this.projVert[0].y,this.size,0,m),a.fill(),a.stroke())}function k(a,b){a.textNode=null;a.lineCap="round";a.lineJoin="round";a.lineWidth=.4;a.beginPath();a.moveTo(this.projVert[0].x,this.projVert[0].y);l=1;for(w=this.projVert.length;l<w;l++)a.lineTo(this.projVert[l].x,this.projVert[l].y);a.closePath();"color"===
this.model?(a.fillStyle=0>this.direction?this.backColor:this.frontColor,a.strokeStyle=a.fillStyle,a.stroke(),a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=b.computeColor(0>this.direction?this.backColor:this.frontColor,this,"metal"===this.model),a.strokeStyle=a.fillStyle,a.stroke(),a.fill()):"wire"===this.model&&(a.lineWidth=1.25,a.strokeStyle=this.frontColor,a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle=this.edges,a.stroke())}function f(a){a.textNode=
null;a.oldTextNode="_a1b2c3_";g=this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,this.familyValue);this.fontSize=Math.max(5,this.evaluator.eval(this.font_size));this.font=this.font_style+" "+this.fontSize+"px "+this.font_family;this.drawText(a,this.text,this.projVert[0].x,this.projVert[0].y,this.frontColor,this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,g)}function n(a){a.textNode=null;a.lineCap="round";a.lineJoin="round";
a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor;a.beginPath();a.moveTo(this.projVert[0].x,this.projVert[0].y);a.lineTo(this.projVert[1].x,this.projVert[1].y);"dot"===this.lineDash?(a.lineCap="butt",a.setLineDash([a.lineWidth,a.lineWidth])):"dash"===this.lineDash?(a.lineCap="butt",a.setLineDash([4*a.lineWidth,3*a.lineWidth])):"dash_dot"===this.lineDash?(a.lineCap="butt",a.setLineDash([4*a.lineWidth,2*a.lineWidth,a.lineWidth,2*a.lineWidth])):a.setLineDash([]);a.stroke()}function e(b,c,l){return a.normalize3D(a.crossProduct3D(a.subtract3D(b,
c),a.subtract3D(b,l)))}if(a.loadLib)return a;var m=2*Math.PI,d,c,r,g,b,l,w,q;a.Primitive3D=function(a,b){this.space=b;for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);this.projVert=[];this.spaceVertices=[];this.newProjVert=[];this.newSpaceVert=[];"vertex"===this.type?this.draw=h:"face"===this.type?(this.normal=e(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=k):"text"===this.type?this.draw=f:"edge"===this.type&&(this.draw=n);this.isText&&(this.computeDepth=function(){this.normal=
{x:0,y:0,z:0};this.projVert=this.vertices;this.depth=this.vertices[0].z;this.average=this.vertices[0]})};a.Primitive3D.prototype.computeDepth=function(b){this.space=b;this.average={x:0,y:0,z:0};this.removeDoubles();this.normal={x:0,y:1,z:0};this.direction={x:1,y:0,z:0};l=0;for(w=this.vertices.length;l<w;l++)this.spaceVertices[l]=b.rotateVertex(this.vertices[l]),this.average.x+=this.spaceVertices[l].x,this.average.y+=this.spaceVertices[l].y,this.average.z+=this.spaceVertices[l].z;this.average=a.scalarProduct3D(this.average,
1/w);this.average_proy=b.project(this.average);this.depth=a.norm3D(a.subtract3D(b.eye,this.average));2<this.vertices.length&&(this.normal=e(this.spaceVertices[0],this.spaceVertices[1],this.spaceVertices[2]));l=0;for(w=this.vertices.length;l<w;l++)this.newSpaceVert[l]=this.spaceVertices[l],this.projVert[l]=this.newProjVert[l]=b.project(this.spaceVertices[l]);2<this.vertices.length&&(this.direction=e(this.projVert[0],this.projVert[1],this.projVert[2]).z);this.minDistanceToEye=Infinity;this.maxDistanceToEye=
-Infinity;this.minx=Infinity;this.maxx=-Infinity;this.miny=Infinity;this.maxy=-Infinity;l=0;for(w=this.vertices.length;l<w;l++)q=a.norm3D(a.subtract3D(this.spaceVertices[l],b.eye)),this.minDistanceToEye=Math.min(this.minDistanceToEye,q),this.maxDistanceToEye=Math.max(this.maxDistanceToEye,q);l=0;for(w=this.vertices.length;l<w;l++)this.minx>this.projVert[l].x&&(this.minx=this.projVert[l].x),this.maxx<this.projVert[l].x&&(this.maxx=this.projVert[l].x),this.miny>this.projVert[l].y&&(this.miny=this.projVert[l].y),
this.maxy<this.projVert[l].y&&(this.maxy=this.projVert[l].y)};a.Primitive3D.prototype.removeDoubles=function(){if("edge"!==this.type){b=[];l=0;for(w=this.vertices.length;l<w;l++)(1E-8<Math.abs(this.vertices[l].x-this.vertices[(l+1)%w].x)||1E-8<Math.abs(this.vertices[l].y-this.vertices[(l+1)%w].y)||1E-8<Math.abs(this.vertices[l].z-this.vertices[(l+1)%w].z)||1E-8<Math.abs(this.vertices[l].w-this.vertices[(l+1)%w].w))&&b.push(this.vertices[l]);0===b.length&&b.push(this.vertices[0]);this.vertices=b}};
a.Primitive3D.prototype.drawText=function(b,l,g,e,f,h,k,q,u,n,x){d=this.evaluator;b.textNode=l;h=d.eval(this.offset_dist);k=-a.degToRad(d.eval(this.offset_angle));g+=h*Math.cos(k);e+=h*Math.sin(k);b.textNode.pos={x:g,y:e};l.hasContent&&(l.draw(b,f,g,e,!0),r=this.fromPoint?l.textNodes.metrics.w/2:0,c=this.fromPoint?l.textNodes.metrics.h/2:0,l.draw(b,f,g-r,e-c))};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){var c=i2=null,l=ix2=0,g,d;var e=this.vertices;var f=b.vertices;var h=
0;for(d=f.length;h<d;h++){var k=this.intersection(f[h],f[(h+1)%d]);if(null!==k)if(null===c){if(c=k,l=h,2===f.length){i2=c;break}}else if(!a.equals3DEpsilon(k,c,1E-8)){i2=k;ix2=h;break}}if(null!==c&&null!==i2){h=this.isInterior(c)||this.isInterior(i2);var q=g=null;if(!h&&3<=f.length)for(d=0,e=e.length;d<e;d++)if(k=b.intersection(this.vertices[d],this.vertices[(d+1)%e]),null!==k)if(null===g)g=k;else if(!a.equals3DEpsilon(k,g,1E-8)){q=k;break}if(h||null!==g&&null!==q&&b.isInterior(g)&&b.isInterior(q)){q=
!0;e=k=null;if(2===f.length)a.equals3DEpsilon(c,f[0],1E-8)||a.equals3DEpsilon(c,f[1],1E-8)?q=!1:(k=[],k[0]=f[0],k[1]=c,e=[],e[0]=c,e[1]=f[1]);else for(k=[],e=[],h=d=g=0;h<f.length;h++)h<l?k[g++]=f[h]:h==l?(k[g++]=f[h],k[g++]=c,e[d++]=c):h<ix2?e[d++]=f[h]:h==ix2?(e[d++]=f[h],e[d++]=i2,k[g++]=i2):k[g++]=f[h];if(q){c=[];c[0]=new a.Primitive3D({vertices:k,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space);c[0].removeDoubles();c[0].normal=b.normal;c[1]=new a.Primitive3D({vertices:e,
type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space);c[1].removeDoubles();c[1].normal=b.normal;if(2<c[0].vertices.length)return 2<c[1].vertices.length?c:[c[0]];if(2<c[1].vertices.length)return[c[1]]}}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var c=this.vertices;var l=b.vertices;if(0<c.length){var g=a.dotProduct3D(l[0],b.normal);
var d=a.dotProduct3D(c[0],b.normal);if(1E-8>Math.abs(g-d))return!0;for(var e=1,f=c.length;e<f;e++)if(l=a.dotProduct3D(c[e],b.normal),1E-8>Math.abs(g-l)||l>g&&d<g||l<g&&d>g)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,c){var l=this.vertices;if(0<l.length){c=a.subtract3D(c,b);var g=a.dotProduct3D(c,this.normal);if(0!==g&&(l=a.dotProduct3D(a.subtract3D(l[0],b),this.normal)/g,-1E-8<l&&1.00000001>l))return a.add3D(b,a.scalarProduct3D(c,l))}return null};a.Primitive3D.prototype.isInterior=
function(b){var c=this.vertices;if(0<c.length)for(var l=0,g=a.subtract3D(c[0],b),d=0,e=c.length;d<e;d++){var f=a.subtract3D(c[(d+1)%e],b),h=a.dotProduct3D(a.crossProduct3D(g,f),this.normal);if(1E-8>Math.abs(h)){if(0>a.dotProduct3D(g,f))break}else{if(0>l&&0<h||0<l&&0>h)return!1;g=f;l=h}}return!0};var u,x,p,v,y;a.Primitive3D.prototype.inFrontOf=function(a,b,c){if(this.minDistanceToEye>=b.maxDistanceToEye||this.maxx<=b.minx||this.minx>=b.maxx||this.maxy<=b.miny||this.miny>=b.maxy)return!1;for(v=0;3>
v;v++)if(u=null,u=0===v?this.intersections(b):1===v?b.verticesContainedIn(this):this.verticesContainedIn(b),null!=u&&0<u.length){for(y=0;y<u.length;y++)a.push(u[y]);l=0;for(w=u.length;l<w;l++){x=u[l];p=this.space.rayFromEye(x.x,x.y);try{t=this.distanceToEyeAlong(p)-b.distanceToEyeAlong(p);if(t<=-c)return!0;if(t>=c)return!1}catch(G){}}}return!1};a.Primitive3D.prototype.intersections=function(b){for(var c=[],l,g,d,e=new a.R2,f=this.newSpaceVert,h=b.newSpaceVert,k=this.newProjVert,q=b.newProjVert,u=
0,n=f.length;u<n;u++){b=f[u];l=f[(u+1)%n];for(var x=0,r=h.length;x<r;x++)g=h[x],d=h[(x+1)%r],b!=g&&b!=d&&l!=g&&l!=d&&(g=e.intersection(k[u],k[(u+1)%n],q[x],q[(x+1)%r]),null!=g&&c.push(g))}return c};a.Primitive3D.prototype.distanceToEyeAlong=function(b){b=a.dotProduct3D(this.normal,b);if(1E-6<Math.abs(b))return a.dotProduct3D(a.subtract3D(this.average,this.space.eye),this.normal)/b;throw new Exception("Face is invisible");};a.Primitive3D.prototype.verticesContainedIn=function(a){for(var b=[],c=this.newSpaceVert,
l=this.newProjVert,g=0,d=c.length;g<d;g++)!a.isVertex(c[g])&&a.appearsToContain(l[g])&&b.push(l[g]);return b};a.Primitive3D.prototype.appearsToContain=function(a){for(var b=0,c,l=this.newProjVert,g=0,d=this.newSpaceVert.length;g<d;g++){c=(l[g].x-a.x)*(l[(g+1)%d].y-a.y)-(l[(g+1)%d].x-a.x)*(l[g].y-a.y);if(0!=b)if(1E-8>Math.abs(c)){if(1E-8<Math.abs(l[g].x-l[(g+1)%d].x))return Math.min(l[g].x,l[(g+1)%d].x)<=a.x+1E-8&&a.x<=Math.max(l[g].x,l[(g+1)%d].x)+1E-8;if(1E-8<Math.abs(l[g].y-l[(g+1)%d].y))return Math.min(l[g].y,
l[(g+1)%d].y)<=a.y+1E-8&&a.y<=Math.max(l[g].y,l[(g+1)%d].y)+1E-8}else if(0<b&&0>c||0>b&&0<c)return!1;b=c}return!0};a.Primitive3D.prototype.isVertex=function(b){for(var c=this.newSpaceVert,l=0,g=c.length;l<g;l++)if(a.equals3DEpsilon(b,c[l],1E-8))return!0;return!1};return a}(descartesJS||{});
descartesJS=function(a){function h(a){for(var c=[],b=0,l,d=a.length,e=a.length-1;-1<e;e--)l=a.charAt(e),0==b?"="==l&&(b=1):1==b?" "!=l&&(b="<"===l||">"===l?0:2):2==b&&" "==l&&(c.unshift(a.substring(e+1,d)),d=e,b=0);c.unshift(a.substring(0,d));return c}if(a.loadLib)return a;var k={x:0,y:0,z:0},f,n,e,m,d=a.degToRad;a.Graphic3D=function(c,g){this.parent=c;this.evaluator=c.evaluator;var b=c.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=b.parse("1");this.abs_coord=!1;this.family="";this.family_interval=b.parse("[0,1]");this.family_steps=b.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=b.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=b.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=b.parse("(0,0,0)");this.model="color";for(var l in g)g.hasOwnProperty(l)&&
(this[l]=g[l]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=b.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font_str=this.font;this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/([\d\.]+)px/))?parseFloat(this.fontSize[1]):10;this.font_style=a.getFontStyle(this.font_str.split(",")[1]);if("boolean"===typeof this.bold||"boolean"===typeof this.italics)this.bold&&
!this.italics?this.font_style="Bold ":!this.bold&&this.italics?this.font_style="Italic ":this.bold&&this.italics?this.font_style="Italic Bold ":this.bold||this.italics||(this.font_style=" ");this.font_family||(this.font_family=this.font_str.split(",")[0]);this.font_family=a.getFontName(this.font_family);"undefined"===typeof this.font_size&&(this.font_size=c.evaluator.parser.parse(this.fontSize.toString()));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=b.parse(this.inirot);this.endrot=b.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,c,b=0,l=a.length;b<l;b++)if(c=a[b],c.id==this.spaceID)return c;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){f=this.evaluator;n=f.eval(this.family_interval);this.familyInf=n[0][0];this.familySup=n[0][1];this.fSteps=Math.round(f.eval(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){f=this.evaluator;this.getFamilyValues();e=f.getVariable(this.family);if(0<=this.fSteps)for(var a=
0,c=this.fSteps;a<=c;a++)f.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,f.eval(this.drawif)&&this.buildPrimitives();f.setVariable(this.family,e)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.eval(this.drawif)&&(this.family||this.buildPrimitives());this.family&&this.buildFamilyPrimitives()};a.Graphic3D.prototype.updateMVMatrix=function(){tmpExpr=this.evaluator.eval(this.inirot);this.inirotEuler?(this.inirotM=
this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(d(tmpExpr[0][0])),this.inirotM=this.inirotM.rotateX(d(tmpExpr[0][1])),this.inirotM=this.inirotM.rotateZ(d(tmpExpr[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(d(tmpExpr[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(d(tmpExpr[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(d(tmpExpr[0][2])));tmpExpr=this.evaluator.eval(this.inipos);k={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.iniposM=
this.iniposM.setIdentity().translate(k);tmpExpr=this.evaluator.eval(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(d(tmpExpr[0][0])),this.endrotM=this.endrotM.rotateX(d(tmpExpr[0][1])),this.endrotM=this.endrotM.rotateZ(d(tmpExpr[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(d(tmpExpr[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(d(tmpExpr[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(d(tmpExpr[0][2])));
tmpExpr=this.evaluator.eval(this.endpos);k={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.endposM=this.endposM.setIdentity().translate(k)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?m=this.inirotM.multiplyVector4(a):(m=this.inirotM_X.multiplyVector4(a),m=this.inirotM_Y.multiplyVector4(m),m=this.inirotM_Z.multiplyVector4(m));m=this.iniposM.multiplyVector4(m);this.endrotEuler?m=this.endrotM.multiplyVector4(m):(m=this.endrotM_X.multiplyVector4(m),m=this.endrotM_Y.multiplyVector4(m),
m=this.endrotM_Z.multiplyVector4(m));m=this.endposM.multiplyVector4(m);this.macroChildren&&(m=this.applyMacroTransform(m));m.adjustDec();return m};a.Graphic3D.prototype.applyMacroTransform=function(a){this.macro_inirotEuler?m=this.macro_inirotM.multiplyVector4(a):(m=this.macro_inirotM_X.multiplyVector4(a),m=this.macro_inirotM_Y.multiplyVector4(m),m=this.macro_inirotM_Z.multiplyVector4(m));m=this.macro_iniposM.multiplyVector4(m);this.macro_endrotEuler?m=this.macro_endrotM.multiplyVector4(m):(m=this.macro_endrotM_X.multiplyVector4(m),
m=this.macro_endrotM_Y.multiplyVector4(m),m=this.macro_endrotM_Z.multiplyVector4(m));return m=this.macro_endposM.multiplyVector4(m)};a.Graphic3D.prototype.parseExpression=function(){for(var a=this.expresion.split(";"),c=[],b=0,l=a.length;b<l;b++)""!==a[b].trim()&&(c=c.concat(h(a[b])));b=0;for(l=c.length;b<l;b++)c[b]=this.evaluator.parser.parse(c[b],!0);return c};var c;a.Graphic3D.prototype.splitFace=function(a){for(var g=0,b=this.primitives.length;g<b;g++)if(c=[],"face"===this.primitives[g].type){for(var l=
0,d=a.primitives.length;l<d;l++)"face"===a.primitives[l].type?c=c.concat(this.primitives[g].splitFace(a.primitives[l])):c.push(a.primitives[l]);a.primitives=c}};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e;a.Point3D=function(e,d){a.Graphic3D.call(this,e,d)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){h=this.evaluator;this.updateMVMatrix();k=h.eval(this.expresion);f=k[0][0];n=k[0][1];e=k[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(f,n,e,1))],type:"vertex",backColor:this.backcolor.getColor(),frontColor:this.color.getColor(),size:h.eval(this.width)}));""!==this.text&&
(this.offset_dist=this.offset_dist||h.parser.parse("10"),this.offset_angle=this.offset_angle||h.parser.parse("270"),this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(f,n,e,1))],type:"text",fromPoint:!0,frontColor:this.color.getColor(),font_size:this.font_size,font_style:this.font_style,font_family:this.font_family,decimals:h.eval(this.decimals),fixed:this.fixed,evaluator:h,text:new a.TextObject(this,this.text),family:this.family,familyValue:this.familyValue,offset_dist:this.offset_dist,
offset_angle:this.offset_angle},this.space)))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d;a.Segment3D=function(c,d){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,d)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();d=evaluator.getVariable("u");evaluator.setVariable("u",this.Nu);expr=evaluator.eval(this.expresion);h=expr[0][0];k=expr[0][1];f=expr[0][2];n=expr[1][0];e=expr[1][1];m=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,
k,f,1)),this.transformVertex(new a.Vector4D(n,e,m,1))],type:"edge",lineDash:this.lineDash,frontColor:this.color.getColor(),lineWidth:evaluator.eval(this.width)},this.space));evaluator.setVariable("u",d)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r,g,b,l,w,q;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(){h=this.evaluator;this.updateMVMatrix();n=h.getVariable("x");e=h.getVariable("y");m=h.getVariable("z");k=h.getVariable("u");
f=h.getVariable("v");h.setVariable("u",0);h.setVariable("v",0);d=parseInt(h.eval(this.Nu));c=parseInt(h.eval(this.Nv));r=[];for(b=0;b<=d;b++)for(h.setVariable("u",b/d),l=0;l<=c;l++){h.setVariable("v",l/c);w=0;for(q=this.expresion.length;w<q;w++)h.eval(this.expresion[w]);r.push(this.transformVertex(new a.Vector4D(h.getVariable("x"),h.getVariable("y"),h.getVariable("z"),1)))}var u=this.color.getColor(),x=this.backcolor.getColor(),p=this.edges?this.edges.getColor():"";for(b=0;b<d;b++)for(l=0;l<c;l++)g=
[],g.push(r[l+b*c+b]),g.push(r[l+1+b*c+b]),g.push(r[l+2+(b+1)*c+b]),g.push(r[l+1+(b+1)*c+b]),this.primitives.push(new a.Primitive3D({vertices:g,type:"face",frontColor:u,backColor:x,edges:p,model:this.model},this.space));h.setVariable("x",n);h.setVariable("y",e);h.setVariable("z",m);h.setVariable("u",k);h.setVariable("v",f)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m;a.Polygon3D=function(d,c){this.width=d.evaluator.parser.parse("1");a.Graphic3D.call(this,d,c)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);for(var d=this.color.getColor(),c=0,r=expr.length-1;c<r;c++)h=expr[c][0],k=expr[c][1],f=expr[c][2],n=expr[c+1][0],e=expr[c+1][1],m=expr[c+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,
k,f,1)),this.transformVertex(new a.Vector4D(n,e,m,1))],type:"edge",frontColor:d,lineWidth:evaluator.eval(this.width)},this.space))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m;a.Curve3D=function(d,c){this.width=d.evaluator.parser.parse("1");a.Graphic3D.call(this,d,c);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();n=evaluator.getVariable("x");e=evaluator.getVariable("y");m=evaluator.getVariable("z");f=evaluator.getVariable("u");evaluator.setVariable("u",0);k=evaluator.eval(this.Nu);h=[];for(var d=
0;d<=k;d++){evaluator.setVariable("u",d/k);for(var c=0,r=this.expresion.length;c<r;c++)evaluator.eval(this.expresion[c]);h.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}d=0;for(c=h.length-1;d<c;d++)this.primitives.push(new a.Primitive3D({vertices:[h[d],h[d+1]],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.eval(this.width)},this.space));this.fill&&2<h.length&&this.primitives.push(new a.Primitive3D({vertices:h,
type:"face",frontColor:this.fill.getColor(),backColor:this.fill.getColor(),edges:"",model:this.model},this.space));evaluator.setVariable("x",n);evaluator.setVariable("y",m);evaluator.setVariable("z",e);evaluator.setVariable("u",f)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r;a.Triangle3D=function(c,b){a.Graphic3D.call(this,c,b)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);h=expr[0][0];k=expr[0][1];f=expr[0][2];n=expr[1][0];e=expr[1][1];m=expr[1][2];d=expr[2][0];c=expr[2][1];r=expr[2][2];var g=this.edges?this.edges.getColor():"";this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,
k,f,1)),this.transformVertex(new a.Vector4D(d,c,r,1)),this.transformVertex(new a.Vector4D(n,e,m,1))],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:g,model:this.model},this.space))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h;a.Face3D=function(h,f){a.Graphic3D.call(this,h,f)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);h=[];for(var k=expr.length-1;0<=k;k--)h.push(this.transformVertex(new a.Vector4D(expr[k][0],expr[k][1],expr[k][2],1)));k=this.edges?this.edges.getColor():"";this.primitives.push(new a.Primitive3D({vertices:h,type:"face",frontColor:this.color.getColor(),
backColor:this.backcolor.getColor(),edges:k,model:this.model},this.space))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e;a.Polireg3D=function(e,d){this.width=e.evaluator.parser.parse("2");this.length=e.evaluator.parser.parse("2");a.Graphic3D.call(this,e,d)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();h=evaluator.eval(this.Nu);k=[this.transformVertex(new a.Vector4D(0,0,0,1))];f=evaluator.eval(this.width)/2;n=evaluator.eval(this.length)/2;e=2*Math.PI/h;for(var m=0;m<h;m++)k.push(this.transformVertex(new a.Vector4D(f*
Math.cos(e*m),n*Math.sin(e*m),0,1)));var d=this.color.getColor(),c=this.backcolor.getColor(),r=this.edges?this.edges.getColor():"";for(m=0;m<h;m++)this.primitives.push(new a.Primitive3D({vertices:[k[0],m+2<=h?k[m+2]:k[1],k[m+1]],type:"face",frontColor:d,backColor:c,edges:r,model:this.model},this.space))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n;a.Text3D=function(e,f){a.Graphic3D.call(this,e,f)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){h=this.evaluator;k=h.eval(this.expresion);f=k[0][0];n=k[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(f,n,0,1)],type:"text",frontColor:this.color.getColor(),font_size:this.font_size,font_style:this.font_style,font_family:this.font_family,decimals:h.eval(this.decimals),fixed:this.fixed,displace:0,
isText:!0,evaluator:h,text:new a.TextObject(this,this.text),family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{});
descartesJS=function(a,h){if(a.loadLib)return a;var k=new String("-point-segment-polygon-curve-triangle-face-polireg-surface-text-cube-box-tetrahedron-octahedron-sphere-dodecahedron-icosahedron-ellipsoid-cone-cylinder-torus-mesh-macro-"),f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,n,e,m=0;a.Macro3D=function(d,c){this.expresion=void 0;this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=d.evaluator.parser.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=d.evaluator.parser.parse("(0,0,0)");
this.name="_descartes_empty_name_"+m++;a.Graphic.call(this,d,c);for(var e in c)c.hasOwnProperty(e)&&(this[e]=c[e]);this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=this.evaluator.parser.parse(this.inirot);this.endrot=this.evaluator.parser.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=
new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4;this.graphics=[];d=d.lessonParser;var g=new a.Tokenizer;if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);c=this.evaluator.eval(this.expresion);if(c)var b=(b=document.getElementById(c))&&"descartes/macro"==
b.type?b.text:a.openExternalFile(c);if(b){var l=b.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&").replace(/\r/g,"").split("\n");
b=[];c=0;for(e=l.length;c<e;c++){var n=l[c].indexOf("=");if(-1!==n){n=d.split(l[c]);for(var q=0,u=n.length;q<u;q++)if(n[q]&&1<n.length&&("id"===h[n[q][0]]||"type"===h[n[q][0]])){b.push(n);break}}}c=0;for(e=b.length;c<e;c++){u=(q=b[c]||[],q[0])&&"id"===q[0][0];var x=!1;l=0;for(n=q.length;l<n;l++){var p=q[l][0].indexOf(".");-1===p||u?p=h[q[l][0]]:(p=h[q[l][0].substring(p+1)],q[l][0]=this.name+"."+q[l][0]);"type"===p&&"surface"===h[q[l][1]]&&(x=!0);if(!("font"===p||"font_family"===p||("fill"===p||"color"===
p||"backcolor"===p||"arrow"===p)&&"("!==q[l][1].charAt(0)||"file"===p&&q[l][1].match(f)||"id"!==p&&void 0!==h[q[l][1]]||x&&"expresion"===p)||"width"===p||"height"===p||"length"===p)if("text"==p)if(q[l][1].match(/\{\\rtf1/)){p=q[l][1];var v=this;var y=function(b,c){c=g.tokenize(c.replace(/&squot;/g,"'"));for(var l=0,d=c.length;l<d;l++)"identifier"!=c[l].type||a.reservedIds.match("-"+c[l].value+"-")||(c[l].value=v.name+"."+c[l].value);return(b.match(/^\\expr/)?"\\expr ":"\\decimals ")+g.flatTokens(c)};
p=p.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,y);p=p.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,y);q[l][1]=p}else{y=d.parseText(q[l][1]).textElementsMacros;for(var A=0,C=y.length;A<C;A++){p=g.tokenize(y[A].replace(/&squot;/g,"'"));for(var I=0,G=p.length;I<G;I++)"identifier"!==p[I].type||a.reservedIds.match("-"+p[I].value+"-")||(p[I].value=this.name+"."+p[I].value);p=g.flatTokens(p).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,
"]");y[A]=p.substring(1,p.length-1)}q[l][1]=y.join("")}else{y=q[l][1].replace(/&squot;/g,"'").split(";");A=0;for(C=y.length;A<C;A++){p=g.tokenize(y[A].replace(/\\n/g,";"));I=0;for(G=p.length;I<G;I++)"identifier"!==p[I].type||a.reservedIds.match("-"+p[I].value+"-")||(p[I].value=this.name+"."+p[I].value);y[A]=g.flatTokens(p)}q[l][1]=y.join(";")}}}c=0;for(e=b.length;c<e;c++)if(b[c][0]){q="";u=!1;l=0;for(n=b[c].length;l<n;l++)"type"===h[b[c][l][0]]&&k.match("-"+h[b[c][l][1]]+"-")&&(u=!0),q=q+b[c][l][0]+
"='"+b[c][l][1]+"' ";b[c]=q+(u?" space='"+this.spaceID+"'":"");u?this.graphics.push(d.parse3DGraphic(b[c],this.abs_coord,this.background,this.inirot)):d.parseAuxiliar(b[c])}}c=0;for(e=this.graphics.length;c<e;c++)this.graphics[c].macroChildren=!0}};a.extend(a.Macro3D,a.Graphic);a.Macro3D.prototype.buildFamilyPrimitives=function(){evaluator=this.evaluator;this.getFamilyValues();var a=evaluator.getVariable(this.family);if(0<=this.fSteps)for(var c=0,e=this.fSteps;c<=e;c++)evaluator.setVariable(this.family,
this.familyInf+c*this.family_sep),this.familyValue=this.familyInf+c*this.family_sep,evaluator.eval(this.drawif)&&this.updateMacro();evaluator.setVariable(this.family,a)};a.Macro3D.prototype.update=function(){this.primitives=[];this.evaluator.eval(this.drawif)&&(this.family||this.updateMacro());this.family&&this.buildFamilyPrimitives()};a.Macro3D.prototype.updateMacro=function(){this.updateTransformation();if(this.inipos){var a=this.evaluator.eval(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}a=
0;for(var c=this.graphics.length;a<c;a++)n=this.graphics[a],n.macro_inirotEuler=this.inirotEuler,n.macro_inirotM=this.inirotM,n.macro_inirotM_X=this.inirotM_X,n.macro_inirotM_Y=this.inirotM_Y,n.macro_inirotM_Z=this.inirotM_Z,n.macro_iniposM=this.iniposM,n.macro_endrotEuler=this.endrotEuler,n.macro_endrotM=this.endrotM,n.macro_endrotM_X=this.endrotM_X,n.macro_endrotM_Y=this.endrotM_Y,n.macro_endrotM_Z=this.endrotM_Z,n.macro_endposM=this.endposM,n.update();a=0;for(c=this.graphics.length;a<c;a++){n=
this.graphics[a];if(n.split||this.split)for(var f=a+1;f<c;f++)e=this.graphics[f],(e.split||this.split)&&n.splitFace(e);this.primitives=this.primitives.concat(n.primitives||[])}};a.Macro3D.prototype.updateTransformation=function(){tmpExpr=this.evaluator.eval(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(tmpExpr[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][2]))):
(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.eval(this.inipos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.iniposM=this.iniposM.setIdentity().translate(translate);tmpExpr=this.evaluator.eval(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=
this.endrotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(tmpExpr[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.eval(this.endpos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};
this.endposM=this.endposM.setIdentity().translate(translate)};a.Macro3D.prototype.drawAux=function(a){};return a}(descartesJS||{},babel);
descartesJS=function(a){function h(a,b,c,l,g){k.call(this,a/x,a/x,a/x,l,g)}function k(a,b,c,l,g){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,l,g)||(this.vertices=[new p(a,c,b,1),new p(a,-c,b,1),new p(a,c,-b,1),new p(a,-c,-b,1),new p(-a,c,b,1),new p(-a,-c,b,1),new p(-a,c,-b,1),new p(-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,l,g))}function f(a,b,c,l,g){a/=2;if(!this.changeGeometry(a,b,c,l,g)){var d=2*Math.PI/3,e=2*a*Math.sqrt(2)/3,f=-a/
3,h=e*Math.cos(d)+0*Math.sin(d);d=-e*Math.sin(d)+0*Math.cos(d);this.vertices=[new p(0,0,a,1),new p(h,d,f,1),new p(h,-d,f,1),new p(e,0,f,1)];this.faces=[[1,3,2],[0,1,2],[0,2,3],[0,3,1]];this.updateValues(a,b,c,l,g)}}function n(a,b,c,l,g){a/=2;this.changeGeometry(a,b,c,l,g)||(this.vertices=[new p(0,0,a,1),new p(a,0,0,1),new p(-a,0,0,1),new p(0,a,0,1),new p(0,-a,0,1),new p(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,l,g))}function e(b,
c,l,g,d){b/=Math.PI;if(!this.changeGeometry(b,c,l,g,d)){F=b/1.6180339887;L=1.6180339887*b;this.vertices=[new p(b,b,b,1),new p(b,b,-b,1),new p(b,-b,b,1),new p(b,-b,-b,1),new p(-b,b,b,1),new p(-b,b,-b,1),new p(-b,-b,b,1),new p(-b,-b,-b,1),new p(0,F,L,1),new p(0,F,-L,1),new p(0,-F,L,1),new p(0,-F,-L,1),new p(F,L,0,1),new p(F,-L,0,1),new p(-F,L,0,1),new p(-F,-L,0,1),new p(L,0,F,1),new p(L,0,-F,1),new p(-L,0,F,1),new p(-L,0,-F,1)];N=(new a.Matrix4x4).setIdentity().rotateY(-q/6);D=0;for(J=this.vertices.length;D<
J;D++)this.vertices[D]=N.multiplyVector4(this.vertices[D]);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,l,g,d)}}function m(b,c,l,g,d){b/=3.8;if(!this.changeGeometry(b,c,l,g,d)){L=1.6180339887*b;this.vertices=[new p(0,b,L,1),new p(0,b,-L,1),new p(0,-b,L,1),new p(0,-b,-L,1),new p(b,L,0,1),new p(b,-L,0,1),new p(-b,L,0,1),new p(-b,-L,0,1),
new p(L,0,b,1),new p(L,0,-b,1),new p(-L,0,b,1),new p(-L,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]];N=(new a.Matrix4x4).setIdentity().rotateY(-1.0285);D=0;for(J=this.vertices.length;D<J;D++)this.vertices[D]=N.multiplyVector4(this.vertices[D]);this.updateValues(b,c,l,g,d)}}function d(a,b,c,g,d){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,
b,c,g,d)){this.vertices=[new p(0,0,b,1)];for(D=1;D<g;D++)for(K=D*q/g,H=0;H<d;H++)G=H*u/d,A=a*l(K)*w(G),C=c*l(K)*l(G),I=b*w(K),this.vertices.push(new p(A,C,I,1));this.vertices.push(new p(0,0,-b,1));this.faces=[];for(D=0;D<d;D++)this.faces.push([0,(D+1)%d+1,D%d+1]);for(D=1;D<g-1;D++)for(H=0;H<d;H++)this.faces.push([H+1+(D-1)*d,(H+1)%d+1+(D-1)*d,(H+1)%d+1+D*d,H+1+D*d]);for(D=0;D<d;D++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+D,this.vertices.length-1-d+(D+1)%d]);this.updateValues(a,
b,c,g,d)}}function c(a,b,c,g,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,g,d)){this.vertices=[];for(D=0;D<d;D++)for(H=0;H<g;H++)A=a*(d-D)/d*w(H*u/g),C=c*(d-D)/d*l(H*u/g),I=b-2*D*b/d,this.vertices.push(new p(A,C,I,1));this.vertices.push(new p(0,0,-b,1));this.faces=[];for(D=0;D<d-1;D++)for(H=0;H<g;H++)this.faces.push([H+D*g,(H+1)%g+D*g,(H+1)%g+(D+1)*g,H+(D+1)*g]);for(D=0;D<g;D++)this.faces.push([this.vertices.length-1,this.vertices.length-1-g+D,this.vertices.length-1-g+(D+1)%g]);this.updateValues(a,
b,c,g,d)}}function r(a,b,c,g,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,g,d)){this.vertices=[];for(D=0;D<d+1;D++)for(H=0;H<g;H++)A=a*w(H*u/g),C=c*l(H*u/g),I=b-2*D*b/d,this.vertices.push(new p(A,C,I,1));this.faces=[];for(D=0;D<d;D++)for(H=0;H<g;H++)this.faces.push([H+D*g,(H+1)%g+D*g,(H+1)%g+(D+1)*g,H+(D+1)*g]);this.updateValues(a,b,c,g,d)}}function g(a,b,c,g,d){a/=2;b/=2;c/=2;E=v.eval(this.R);z=v.eval(this.r);if(!this.changeGeometry(a,b,c,g,d)){this.vertices=[];for(D=0;D<d+1;D++)for(H=0;H<g;H++)A=
-(E+z*l(u*H/g))*l(u*D/d),C=(E+z*l(u*H/g))*w(u*D/d),I=z*w(u*H/g),this.vertices.push(new p(A,C,I,1));this.faces=[];for(D=0;D<d;D++)for(H=0;H<g;H++)this.faces.push([H+D*g,H+(D+1)*g,(H+1)%g+(D+1)*g,(H+1)%g+D*g]);this.updateValues(a,b,c,g,d)}}function b(){function a(a){return parseInt(a)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];D=0;for(J=this.fileData.length;D<J;D++)M=this.fileData[D],M.match(/^V\(/)?(B=M.substring(2,M.length-1).split(",").map(b),this.vertices.push(new p(B[0]||
0,B[1]||0,B[2]||0,1))):M.match(/^F\(/)&&(B=M.substring(2,M.length-1).split(",").map(a),this.faces.push(B.reverse()))}if(a.loadLib)return a;var l=Math.sin,w=Math.cos,q=Math.PI,u=2*q,x=Math.sqrt(3),p,v,y,A,C,I,G,K,E,z,F,L,N,M,B,D,J,H,P;a.OtherGeometry=function(l,q){this.width=l.evaluator.parser.parse("2");this.height=l.evaluator.parser.parse("2");this.length=l.evaluator.parser.parse("2");this.R=l.evaluator.parser.parse("2");this.r=l.evaluator.parser.parse("1");p=a.Vector4D;a.Graphic3D.call(this,l,q);
switch(this.type){case "cube":this.buildGeometry=h;break;case "box":this.buildGeometry=k;break;case "tetrahedron":this.buildGeometry=f;break;case "octahedron":this.buildGeometry=n;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=d;break;case "dodecahedron":this.buildGeometry=e;break;case "icosahedron":this.buildGeometry=m;break;case "cone":this.buildGeometry=c;break;case "cylinder":this.buildGeometry=r;break;case "torus":this.buildGeometry=g;break;case "mesh":this.fileData=
a.openExternalFile(this.evaluator.eval(this.file)).split(/\r/),this.buildGeometry=b}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=function(){v=this.evaluator;this.updateMVMatrix();this.buildGeometry(v.eval(this.width),v.eval(this.height),v.eval(this.length),v.eval(this.Nu),v.eval(this.Nv));var b=this.color.getColor(),c=this.backcolor.getColor(),l=this.edges?this.edges.getColor():"";D=0;for(J=this.faces.length;D<J;D++){y=[];H=0;for(P=this.faces[D].length;H<P;H++)y.push(this.transformVertex(this.vertices[this.faces[D][H]]));
this.primitives.push(new a.Primitive3D({vertices:y,type:"face",frontColor:b,backColor:c,edges:l,model:this.model},this.space))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,c,l,g){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===l&&this.oldNv===g};a.OtherGeometry.prototype.updateValues=function(a,b,c,l,g){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=g;this.oldNu=l};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.max,k=Math.min,f=Math.PI,n=Math.cos,e=Math.sin,m=Math.abs,d=Math.round,c,r,g,b,l,w,q,u,x,p,v,y,A,C,I,G,K,E;a.R2=function(a,b){this.x=void 0===a?0:a;this.y=void 0===b?0:b};a.R2.prototype.set=function(a,b){this.x=void 0===a?0:a;this.y=void 0===b?0:b;return this};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return d(h(k(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return d(h(k(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){r=this.copy();r.sub(a);return r.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(){c=this.norm();0!=c&&this.div(c)};a.R2.prototype.rotR90=function(){c=this.x;this.x=this.y;this.y=-c};a.R2.prototype.rotL90=function(){c=this.x;this.x=-this.y;this.y=c};a.R2.prototype.rot=function(a){g=this.copy();w=n(a);q=e(a);this.x=g.x*w-g.y*q;this.y=g.x*q+g.y*w};a.R2.prototype.rot=function(a){this.rot(a*f/180)};a.R2.prototype.intersection=function(c,
g,d,e){u=g.x-c.x;x=d.x-e.x;p=d.x-c.x;v=g.y-c.y;y=d.y-e.y;A=d.y-c.y;E=u*y-x*v;return 1E-6<m(E)?(b=(p*y-A*x)/E,l=(-p*v+A*u)/E,0<=b&&1>=b&&0<=l&&1>=l?new a.R2(c.x+u*b,c.y+v*b):null):(g.x-d.x)*A!=(g.y-d.y)*p?null:c.x!=g.x?(C=k(c.x,g.x),I=h(c.x,g.x),C<=d.x&&d.x<=I?d:C<=e.x&&e.x<=I?e:null):d.x!=e.x?(G=k(d.x,e.x),K=h(d.x,e.x),G<=c.x&&c.x<=K?c:G<=g.x&&g.x<=K?g:null):c.y!=g.y?(C=k(c.y,g.y),I=h(c.y,g.y),C<=d.y&&d.y<=I?d:C<=e.y&&e.y<=I?e:null):d.y!=e.y?(G=k(d.y,e.y),K=h(d.y,e.y),G<=c.y&&c.y<=K?c:G<=g.y&&g.y<=
K?g:null):c.x==d.x&&c.y==d.y?c:null};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r;a.R2Newton=function(c,b){this.evaluator=c;this.constraint=b;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];
m=new a.R2(0,0);e=new a.R2(0,0);r=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return r.set(this.normal.x,this.normal.y)};a.R2Newton.prototype.gradient=function(a){h=this.evaluator;m.x=0;m.y=0;d=h.getVariable("x");c=h.getVariable("y");h.setVariable("x",a.x);h.setVariable("y",a.y);this.f0=h.eval(this.constraint);h.setVariable("x",h.getVariable("x")+1E-6);k=h.eval(this.constraint);m.x=(k-this.f0)/1E-6;m.x=isNaN(m.x)?Infinity:m.x;h.setVariable("x",h.getVariable("x")-
1E-6);h.setVariable("y",h.getVariable("y")+1E-6);k=h.eval(this.constraint);m.y=(k-this.f0)/1E-6;m.y=isNaN(m.y)?Infinity:m.y;h.setVariable("x",d);h.setVariable("y",c);return m};a.R2Newton.prototype.findZero=function(a,b,l){h=this.evaluator;e.x=a.x;e.y=a.y;d=h.getVariable("x");c=h.getVariable("y");h.setVariable("x",a.x);h.setVariable("y",a.y);this.f0=h.eval(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return e;h.setVariable("x",d);h.setVariable("y",c);for(var g=
0;16>g;g++)if(f=e.x,n=e.y,this.normal=this.gradient(e),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),e.x=f+this.normal.x,e.y=n+this.normal.y,this.normal.norm()<b)return 0===this.normal.x&&0===this.normal.y&&(this.normal.x=e.x-a.x,this.normal.y=e.y-a.y),e;return l?e:null};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,k){this.x=a;this.y=k};a.Vector2D.AXIS_X=new a.Vector2D(1,0);a.Vector2D.AXIS_Y=new a.Vector2D(0,1);a.Vector2D.prototype.vectorLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y};a.Vector2D.prototype.angleBetweenVectors=function(a){return Math.acos(this.dotProduct(a)/(this.vectorLength()*a.vectorLength()))};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,k=Math.round,f,n,e,m,d,c,r,g,b,l,w,q,u;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var l=this.parser=b.evaluator.parser;this.id="graphic"!==c.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==c.type?100:350;this.h="video"!==c.type?23:120;"graphic"!==c.type&&"audio"!==c.type&&"video"!==c.type?"text"!==c.type?this.expresion=l.parse("(0,0,100,23)"):(this.expresion=l.parse("(0,0,300,200)"),
this.w=300,this.h=200):this.expresion=l.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=new a.Color(4>this.parent.version?"000000":"222222");this.colorInt=new a.Color("graphic"!==c.type?"f0f8ff":"cc0022");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:l.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=l.parse("1");this.activeif=l.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";
this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=l.parse("0");this.decimals=l.parse("2");this.min=l.parse("-Infinity");this.max=l.parse("Infinity");this.incr=l.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);"video"!==this.type&&"audio"!==this.type||"interior"===this.region||(this.region="interior");void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==
this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;c=this.evaluator.eval(this.expresion);this.x=k(c[0][0]);this.y=k(c[0][1]);4==c[0].length&&(this.w=k(c[0][2]),this.h=k(c[0][3]));this.actionExec=b.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces;if("interior"===this.region)for(var b=0,c=a.length;b<c;b++){var l=a[b];if(l.id===
this.spaceID)return l.addCtr(this),this.zIndex=l.zIndex,this.space=l,l.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.addCtr(this),this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.stage.stageSpace.addCtr(this),this.zIndex=this.parent.stage.stageSpace.zIndex,this.parent.stage.stageSpace.numericalControlContainer):this.parent.externalSpace.container;
if(/north|south|east|west/.test(this.region))return this.parent[this.region+"Space"].controls.push(this),this.parent[this.region+"Space"].container}a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){e=m=d=c=!1;r=this.evaluator.eval(this.expresion);g=k(r[0][0]);e=k(this.x)!==
g;this.x=g;g=k(r[0][1]);m=k(this.y)!==g;this.y=g;4===r[0].length&&(g=k(r[0][2]),d=k(this.w)!==g,this.w=g,g=k(r[0][3]),c=k(this.h)!==g,this.h=g);if(d||c||e||m)this.init(!0),this.draw()};a.Control.prototype.formatOutputValue=function(a){u=this.parent;b=a+"";l=this.evaluator.eval(this.decimals);w=b.indexOf(".");-1!=w&&(q=b.substring(w+1),q.length>l&&(b=parseFloat(b).toFixed(l)));this.fixed&&(2!==u.version||2===u.version&&!this.exponentialif)&&(b=parseFloat(a).toFixed(l));this.exponentialif&&0!=parseFloat(b)&&
(b=this.fixed&&2!==u.version?parseFloat(b).toExponential(l):parseFloat(b).toExponential(),b=b.toUpperCase().replace("+",""));return b.replace(".",u.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();this.parent.updateControls();"animate"!==this.action&&this.parent.update();this.parent.updateControls()};a.Control.prototype.createGradient=function(a,b){this.linearGradient=this.ctx.createLinearGradient(0,
0,0,b);f=b*b;for(a=0;a<b;a++)n=h(a-35*b/100),this.linearGradient.addColorStop(a/b,"rgba(0,0,0,"+n*n*192/f/255+")")};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,k=Math.abs,f,n,e,m,d,c,r,g,b,l,w,q,u,x,p,v=/[\w\.\-//]*(\.gif)/gi,y,A,C,I,G,K,E,z,F,L,N,M,B,D,J,H;a.Button=function(b,c){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;this.borderColor=this.flat=!1;this.image_align=this.text_align="center_center";this.font_family="arial";a.Control.call(this,b,c);this.font_family=a.getFontName(this.font_family);this.ratio=b.ratio;-1===this.font_size&&(this.fontSizeNotSet=
!0);this.borderColor&&(this.borderColor=new a.Color(this.borderColor));this.text_align=this.text_align.split("_");this.image_align=this.image_align.split("_");"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.classContainer=this.cssClass?" "+this.cssClass+" ":"";if(this.imageSrc.trim().match("^_STYLE_")){this.customStyle=!0;this.btnStyle=[];this.conStyle=[];
this.conStyle.textBorder=3;b=this.imageSrc.trim().substring(8).split("|");for(var l,g=0,d=b.length;g<d;g++)c=b[g],l=c.match(/rgb/g),c.match("class=")?this.classContainer=" "+c.substring(6):c.match("border=")?(this.btnStyle.push({type:"border-style",value:"solid"}),this.btnStyle.push({type:"border-width",value:c.substring(7).trim()+"px"})):c.match("borderRadius=")?(this.btnStyle.push({type:"border-radius",value:c.substring(13).trim()+"px"}),this.conStyle.push({type:"border-radius",value:c.substring(13).trim()+
"px"})):c.match("borderColor=")?this.btnStyle.push({type:"border-color",value:(l?"":"#")+c.substring(12).trim()}):c.match("overColor=")?this.conStyle.overColor=(l?"":"#")+c.substring(10).trim():c.match("downColor=")?this.conStyle.downColor=(l?"":"#")+c.substring(10).trim():c.match("font=")?this.conStyle.font=c.substring(5).trim().toLowerCase():c.match("inactiveColor=")?this.conStyle.inactiveColor=(l?"":"#")+c.substring(14).trim():c.match("inactiveColorBorder=")?this.conStyle.inactiveColorBorder=(l?
"":"#")+c.substring(20).trim():c.match("shadowTextBlur=")?this.conStyle.shadowTextBlur=parseFloat(c.substring(15).trim()):c.match("shadowTextOffsetX=")?this.conStyle.shadowTextOffsetX=parseFloat(c.substring(18).trim()):c.match("shadowTextOffsetY=")?this.conStyle.shadowTextOffsetY=parseFloat(c.substring(18).trim()):c.match("shadowTextColor=")?this.conStyle.shadowTextColor=(l?"":"#")+c.substring(16).trim():c.match("shadowBoxBlur=")?this.conStyle.shadowBoxBlur=parseFloat(c.substring(14).trim()):c.match("shadowBoxOffsetX=")?
this.conStyle.shadowBoxOffsetX=parseFloat(c.substring(17).trim()):c.match("shadowBoxOffsetY=")?this.conStyle.shadowBoxOffsetY=parseFloat(c.substring(17).trim()):c.match("shadowBoxColor=")?this.conStyle.shadowBoxColor=(l?"":"#")+c.substring(15).trim():c.match("shadowInsetBoxBlur=")?this.conStyle.shadowInsetBoxBlur=parseFloat(c.substring(19).trim()):c.match("shadowInsetBoxOffsetX=")?this.conStyle.shadowInsetBoxOffsetX=parseFloat(c.substring(22).trim()):c.match("shadowInsetBoxOffsetY=")?this.conStyle.shadowInsetBoxOffsetY=
parseFloat(c.substring(22).trim()):c.match("shadowInsetBoxColor=")?this.conStyle.shadowInsetBoxColor=(l?"":"#")+c.substring(20).trim():c.match("textBorder=")&&(this.conStyle.textBorder=parseFloat(c.substring(11).trim()));this.imageSrc="vacio.gif"}this.imageSrc.match("_COLORES_")&&(b=this.imageSrc.split("_"),this.colorInt=new a.Color(b[2]),this.color=new a.Color(b[3]),this.font_size=this.parser.parse(b[5]),this.imageSrc="");"["==this.imageSrc.charAt(0)?this.imageSrc=this.parser.parse(this.imageSrc.substring(1,
this.imageSrc.length-1)):this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");b=this.evaluator.eval(this.imageSrc).toString().trim();""!=b&&(c=b.substr(0,b.lastIndexOf(".")),l=b.substr(b.lastIndexOf(".")),b.toLowerCase().match(/vacio.gif$/)?(this.imageSrc=this.parser.parse("'vacio.gif'"),this.image.ready=1,3===this.parent.version&&(this.name=this.parser.parse("")),this.emptyImage={ready:!0},this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(b),c&&(this.imageOver=this.parent.getImage(c+
"_over"+l),this.imageDown=this.parent.getImage(c+"_down"+l))));this.container=document.createElement("div");this.container.setAttribute("class","DescartesButtonContainer"+this.classContainer);this.container.setAttribute("id",this.id);this.container.setAttribute("style","width:"+this.w+"px; height:"+this.h+"px; left:"+this.x+"px; top:"+this.y+"px; z-index:"+this.zIndex+";");this.btn=document.createElement("canvas");this.btn.width=this.w*this.ratio;this.btn.height=this.h*this.ratio;this.btn.setAttribute("style",
"position:absolute; left:0; top:0; width:"+this.w+"px; height:"+this.h+"px; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box;");this.ctx=this.btn.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.container.appendChild(this.btn);this.addControlContainer(this.container);this.addEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(b){f=this.evaluator;y=this.container;n=this.btn;e=this.ctx;m=f.eval(this.expresion);this.x=m[0][0];this.y=
m[0][1];4==m[0].length&&(this.w=parseInt(m[0][2]),this.h=parseInt(m[0][3]));n.width=this.w*this.ratio;n.height=this.h*this.ratio;n.setAttribute("style","position:absolute; left:0; top:0; width:"+this.w+"px; height:"+this.h+"px; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box;");y.setAttribute("style","width:"+this.w+"px; height:"+this.h+"px; left:"+this.x+"px; top:"+this.y+"px; z-index:"+this.zIndex+"; display:block;");if(this.btnStyle)for(var c=0,l=this.btnStyle.length;c<
l;c++)n.style[this.btnStyle[c].type]=this.btnStyle[c].value;if(this.conStyle){c=0;for(l=this.conStyle.length;c<l;c++)y.style[this.conStyle[c].type]=this.conStyle[c].value;if(this.conStyle.shadowBoxColor){c=this.conStyle.shadowBoxOffsetX||0;l=this.conStyle.shadowBoxOffsetY||2;var g=this.conStyle.shadowBoxBlur||2;y.style.boxShadow=c+"px "+l+"px "+g+"px 1px "+this.conStyle.shadowBoxColor}this.conStyle.shadowInsetBoxColor&&(c=this.conStyle.shadowInsetBoxOffsetX||0,l=this.conStyle.shadowInsetBoxOffsetY||
-2,g=this.conStyle.shadowInsetBoxBlur||1,n.style.boxShadow=c+"px "+l+"px "+g+"px 1px "+this.conStyle.shadowInsetBoxColor+" inset");this.conStyle.shadowTextColor&&(e.shadowBlur=this.conStyle.shadowTextBlur||1,e.shadowOffsetX=this.conStyle.shadowTextOffsetX||0,e.shadowOffsetY=this.conStyle.shadowTextOffsetY||2,e.shadowColor=this.conStyle.shadowTextColor)}this.fontSizeNotSet&&(this.font_size=f.parser.parse(a.getFieldFontSize(this.h)+""));this.fs_evaluated=f.eval(this.font_size);this.createGradient(this.w,
this.h);y.style.display=0<f.eval(this.drawif)?"block":"none";e.textAlign="center";e.textBaseline="middle";e.lineJoin="round";e.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px "+this.font_family;this.customStyle&&("serif"==this.conStyle.font?e.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px "+this.font_family:"monospace"==this.conStyle.font&&(e.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px "+a.monospace_font));this.draw(b)};a.Button.prototype.update=function(){f=this.evaluator;
y=this.container;n=this.btn;this.activeIfValue=0<f.eval(this.activeif);this.drawIfValue=0<f.eval(this.drawif);(this.space?this.space.drawIfValue:1)&&this.drawIfValue?(y.style.display="block",this.draw(),y.style.cursor=n.style.cursor=this.activeIfValue?"pointer":"not-allowed",this.updatePositionAndSize()):(y.style.display="none",this.buttonClick=!1)};a.Button.prototype.draw=function(k){y=this.container;f=this.evaluator;n=this.btn;e=this.ctx;c=f.eval(this.name);r=this.evaluator.eval(this.imageSrc).toString().trim();
if(!k&&(A=this.over===this.oldOver,C=this.buttonClick===this.oldButtonClick,I=this.activeIfValue===this.oldActiveIfValue,G=this.drawIfValue===this.oldDrawIfValue,K=c===this.oldName,E=r===this.oldImageSrc,z=this.colorInt.getColor()===this.oldBackColor,F=this.color.getColor()===this.oldTextColor,L=this.image.ready===this.oldImageReady,this.oldOver=this.over,this.oldButtonClick=this.buttonClick,this.oldActiveIfValue=this.activeIfValue,this.oldDrawIfValue=this.drawIfValue,this.oldName=c,this.oldImageSrc=
r,this.oldBackColor=this.colorInt.getColor(),this.oldTextColor=this.color.getColor(),this.oldImageReady=this.image.ready,A&&C&&I&&G&&K&&E&&z&&F&&L))return;e.save();e.setTransform(this.ratio,0,0,this.ratio,0,0);d=this.fs_evaluated;y.setAttribute("data-name",c);r?(g="vacio.gif"===r?this.emptyImage:this.parent.getImage(r),N=r.substr(0,r.lastIndexOf(".")),M=r.substr(r.lastIndexOf(".")),B=N+"_over"+M,D=N+"_down"+M,J="vacio.gif"===r?this.emptyImage:this.parent.getImage(B),H="vacio.gif"===r?this.emptyImage:
this.parent.getImage(D)):H=J=g=this.emptyImage;e.clearRect(0,0,this.w,this.h);b=l=0;this.buttonClick&&(b=l=1);"center"==this.text_align[1]?x=h(this.w/2+b)-.5:"left"==this.text_align[1]?(w=e.measureText(c).width,x=w/2+5+b):"right"==this.text_align[1]&&(w=e.measureText(c).width,x=this.w-w/2+b-5);"center"==this.text_align[0]?p=h(this.h/2+l)-.5:"top"==this.text_align[0]?p=d/2+l+4:"bottom"==this.text_align[0]&&(p=this.h-d/2+l-3);g&&("center"==this.image_align[1]?q=parseInt((this.w-g.width)/2)+b:"left"==
this.image_align[1]?q=b:"right"==this.image_align[1]&&(q=this.w-g.width+b),"center"==this.image_align[0]?u=parseInt((this.h-g.height)/2)+l:"top"==this.image_align[0]?u=l:"bottom"==this.image_align[0]&&(u=this.h-g.height+l));if(g&&g.ready)if(g!==this.emptyImage&&g.complete)if(r.match(v))this.btn.style.backgroundRepeat="no-repeat",this.btn.style.backgroundImage="url('"+r+"')",this.btn.style.backgroundPosition=q+"px "+u+"px";else{if("center"!=this.image_align[0]||"center"!=this.image_align[1])y.style.backgroundColor=
this.colorInt.getColor();e.drawImage(g,q,u)}else this.emptyImage&&this.customStyle&&(y.style.backgroundColor=this.colorInt.getColor());else y.style.backgroundColor=this.colorInt.getColor(),this.flat||(this.buttonClick||(a.drawLine(e,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,0.5)"),a.drawLine(e,0,0,0,this.h,"rgba(0,0,0,0.09)"),a.drawLine(e,1,0,1,this.h,"rgba(0,0,0,0.03)")),e.fillStyle=this.linearGradient,e.fillRect(0,0,this.w,this.h));this.activeIfValue&&(J!==this.emptyImage&&this.over&&J.ready&&J.complete?
B.match(v)?(this.btn.style.backgroundImage="url('"+B+"')",this.btn.style.backgroundPosition=q+"px "+u+"px"):e.drawImage(J,q,u):this.customStyle&&this.conStyle.overColor&&this.over&&(y.style.backgroundColor=this.conStyle.overColor));this.activeIfValue?H!==this.emptyImage&&this.buttonClick&&H.ready&&H.complete?D.match(v)?(this.btn.style.backgroundImage="url('"+D+"')",this.btn.style.backgroundPosition=q+"px "+u+"px"):e.drawImage(H,q,u):this.customStyle&&this.conStyle.downColor&&this.buttonClick&&(y.style.backgroundColor=
this.conStyle.downColor):this.buttonClick&&!g&&(e.fillStyle="rgba(0,0,0,0.09)",e.fillRect(0,0,this.w,this.h));e.fillStyle=this.color.getColor();this.customStyle&&this.conStyle.shadowTextColor&&0<this.conStyle.textBorder&&(e.lineWidth=this.conStyle.textBorder,e.strokeStyle=this.conStyle.shadowTextColor,e.strokeText(c,x,p));this.borderColor&&(e.lineWidth=parseInt(d/7),e.strokeStyle=this.borderColor.getColor(),e.strokeText(c,x,p));e.fillText(c,x,p);this.underlined&&(w=e.measureText(c).width,e.strokeStyle=
this.color.getColor(),e.lineWidth=h(d/10)||2,e.lineCap="round",e.beginPath(),e.moveTo(x-w/2+b,p+h(d/2)+h(d/5)-1.5),e.lineTo(x+w/2+b,p+h(d/2)+h(d/5)-1.5),e.stroke());this.activeIfValue||(this.customStyle&&this.conStyle.inactiveColor?y.style.backgroundColor=this.conStyle.inactiveColor:(e.fillStyle="rgba(240,240,240,0.6)",e.fillRect(0,0,this.w,this.h)));e.restore();this._image_pos_x=q;this._image_pos_y=u};a.Button.prototype.drawTextBorder=function(){this.colorInt.getColor();this.color.getColor();return!(.5>
(k(this.colorInt.r-this.color.r)+k(this.colorInt.g-this.color.g)+k(this.colorInt.b-this.color.b))/255)};a.Button.prototype.buttonPressed=function(){this.updateAndExecAction()};a.Button.prototype.addEvents=function(){function b(c,l,e){a.clearTimeout(d);g.buttonClick&&g.drawIfValue&&g.activeIfValue&&(l.call(g),c=e?c:100,d=a.setTimeout(function(){b(c,l,!1)},c))}function c(c){this.focus();c.preventDefault();c.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();g.whichBtn=
a.whichBtn(c);"L"==g.whichBtn&&g.activeIfValue&&(g.buttonClick=!0,g.draw(),"calculate"==g.action&&(g.evaluator.setVariable(g.id,g.evaluator.eval(g.valueExpr)),b(1E3,g.buttonPressed,!0)),g.btn.removeEventListener("touchend",l),g.btn.addEventListener("touchend",l),g.btn.removeEventListener("mouseup",l),g.btn.addEventListener("mouseup",l))}function l(b){a.newBlobContent=null;this.focus();b.preventDefault();b.stopPropagation();if(g.activeIfValue||g.buttonClick)g.buttonClick=!1,g.draw(),"calculate"!=g.action&&
(g.evaluator.setVariable(g.id,g.evaluator.eval(g.valueExpr)),g.buttonPressed()),g.btn.removeEventListener("touchend",l),g.btn.removeEventListener("mouseup",l);g.parent.update()}var g=this,d;g.btn.oncontextmenu=function(){return!1};this.over=this.buttonClick=!1;this.btn.addEventListener("touchstart",c);this.btn.addEventListener("mousedown",c);this.btn.addEventListener("mouseover",function(a){a.preventDefault();a.stopPropagation();g.over=!0;g.draw()});this.btn.addEventListener("mouseout",function(b){a.newBlobContent=
null;b.preventDefault();b.stopPropagation();g.over=!1;g.buttonClick=!1;g.draw()});document.addEventListener("visibilitychange",function(b){a.newBlobContent=null;g.buttonClick=!1})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r,g,b,l,w,q,u,x,p,v;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;"_._"==this.name&&(this.name="");"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.container=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");
this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.container.appendChild(this.label);this.container.appendChild(this.field);this.container.appendChild(this.canvas);this.container.appendChild(this.divUp);this.container.appendChild(this.divDown);this.addControlContainer(this.container);v=this.evaluator.parser.parse("1");this.originalIncr=this.incr;if(0>this.evaluator.eval(this.decimals)||0==this.evaluator.eval(this.incr))b=
this.evaluator.eval(this.incr),0<b?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(b).toString()):this.incr=v;this.addEvents();this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){h=this.evaluator;var b=h.eval(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(h.eval(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var l=2!==this.parent.version?"__":
"_____",g=a.getTextWidth(c+"_",this.fieldFontSize+"px "+a.sansserif_font),d=2+parseInt(this.h/2),e=parseInt(this.w/2-d/2);l=a.getTextWidth(b+l,this.fieldFontSize+"px "+a.sansserif_font);this.visible||(e=this.w-d,g=0);e<l&&(e=l);""==b&&(e=0);this.w-e-d<g&&(e=this.w-d-g);0>e&&(e=0);b=this.w-(e+d);this.container.setAttribute("class","DescartesSpinnerContainer");this.container.setAttribute("style","width:"+this.w+"px;height:"+this.h+"px;left:"+this.x+"px;top:"+this.y+"px;z-index:"+this.zIndex+";");this.container.setAttribute("id",
this.id);this.canvas.setAttribute("width",d+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position:absolute;left:"+e+"px;top:0;");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;l="opacity:0;cursor:pointer;position:absolute;width:"+d+"px;height:"+this.h/2+"px;left:"+e+"px;";this.divUp.setAttribute("class","up");this.divUp.setAttribute("style",l+"top:0;");this.divDown.setAttribute("class","down");this.divDown.setAttribute("style",l+"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:"+a.sansserif_font+";font-size:"+this.fieldFontSize+"px;width:"+b+"px;height:"+this.h+"px;left:"+(d+e)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.visible||(this.field.style.display="none");this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style",
"font-size:"+this.fieldFontSize+"px;width:"+e+"px;height:"+this.h+"px;line-height:"+this.h+"px;");h.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){h=this.evaluator;this.label.innerHTML=h.eval(this.name).toString();0>h.eval(this.decimals)?(k=h.eval(this.incr),0<k?this.originalIncr=this.incr=h.parser.parse(parseInt(k).toString()):this.incr=v):this.incr=0!==h.eval(this.originalIncr)?this.originalIncr:v;this.activeIfValue=0<h.eval(this.activeif);
this.drawIfValue=0<h.eval(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.container.style.display="block",this.draw()):(this.click=!1,this.container.style.display="none");this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(f=this.field.value,n=this.value,this.value=this.validateValue(h.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value==n&&this.field.value!=f&&(this.value=this.validateValue(f),
this.field.value=this.formatOutputValue(this.value)),h.setVariable(this.id,this.value))};a.Spinner.prototype.draw=function(){e=this.ctx;m=this.canvas.width;d=this.canvas.height;e.fillStyle="#f0f8ff";e.fillRect(0,0,m,d);e.fillStyle=this.linearGradient;e.fillRect(0,0,m,d);this.up?(c="gray",r="#f0f8ff"):(c="#f0f8ff",r="gray");a.drawLine(e,0,0,m,0,c);a.drawLine(e,0,0,0,d/2,c);a.drawLine(e,0,d/2,m,d/2,r);this.down?(c="gray",r="#f0f8ff"):(c="#f0f8ff",r="gray");a.drawLine(e,0,d/2+1,m,d/2+1,c);a.drawLine(e,
0,d/2+1,0,d,c);a.drawLine(e,0,d-1,m,d-1,r);g=[parseInt(m/2+1),parseInt(m/5+1),parseInt(m-m/5+1)];b=[parseInt(d/8+1),parseInt(d/8+1+d/4),parseInt(d/8+1+d/4)];e.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";e.beginPath();e.moveTo(g[0],b[0]);e.lineTo(g[1],b[1]);e.lineTo(g[2],b[2]);e.fill();b=[parseInt(d-d/8),parseInt(d-d/8-d/4),parseInt(d-d/8-d/4)];e.fillStyle=this.activeIfValue?"#d00018":"#aa8888";e.beginPath();e.moveTo(g[0],b[0]);e.lineTo(g[1],b[1]);e.lineTo(g[2],b[2]);e.fill();e.fillStyle="rgba(0,0,0,"+
24/255+")";this.up&&e.fillRect(0,0,m,d/2);this.down&&e.fillRect(0,d/2,m,d)};a.Spinner.prototype.validateValue=function(a){h=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=void 0!=a?a.toString():"0";a=a.replace(this.parent.decimal_symbol,".");l=a==parseFloat(a)?parseFloat(a):parseFloat(h.eval(h.parser.parse(a)));isNaN(l)&&(l=0);u=h.eval(this.min);x=h.eval(this.max);""===u&&(u=-Infinity);""===x&&(x=Infinity);l=Math.min(Math.max(l,u),x);this.discrete&&(w=
h.eval(this.incr),l=0==w?0:w*Math.round(l/w));q=h.eval(this.decimals);0>=q&&(q=0);return l=parseFloat(parseFloat(l).toFixed(q))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.eval(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.eval(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),
this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.addEvents=function(){function b(c,l,g){a.clearTimeout(h);if(e.up||e.down)l.call(e),c=g?c:10,h=a.setTimeout(function(){b(c,l)},c)}function c(c){c.preventDefault();e.whichBtn=a.whichBtn(c);"L"==e.whichBtn&&e.activeIfValue&&(e.up=!0,b(f,e.increase,!0),e.draw())}function l(c){c.preventDefault();e.whichBtn=a.whichBtn(c);"L"==e.whichBtn&&e.activeIfValue&&(e.down=!0,b(f,e.decrease,!0),e.draw())}function g(b){e.up=
!1;a.clearTimeout(h);e.draw()}function d(b){e.down=!1;a.clearTimeout(h);e.draw()}p=a.hasTouchSupport;var e=this,f=p?500:200,h;e.divUp.oncontextmenu=e.divDown.oncontextmenu=e.field.oncontextmenu=e.label.oncontextmenu=function(){return!1};this.label.addEventListener("touchstart",a.preventDefault);this.label.addEventListener("mousedown",a.preventDefault);this.field.addEventListener("keydown",function(a){13==a.keyCode&&e.changeValue(e.field.value)});this.divUp.addEventListener("touchstart",c);this.divUp.addEventListener("mousedown",
c);this.divDown.addEventListener("touchstart",l);this.divDown.addEventListener("mousedown",l);this.divUp.addEventListener("mouseout",function(b){e.up=!1;a.clearTimeout(h);e.draw();b.preventDefault()});this.divDown.addEventListener("mouseout",function(b){e.down=!1;a.clearTimeout(h);e.draw();b.preventDefault()});this.divUp.addEventListener("touchend",g);window.addEventListener("touchend",g);this.divUp.addEventListener("mouseup",g);window.addEventListener("mouseup",g);this.divDown.addEventListener("touchend",
d);window.addEventListener("touchend",d);this.divDown.addEventListener("mouseup",d);window.addEventListener("mouseup",d);document.addEventListener("visibilitychange",function(b){e.up=!1;e.down=!1;a.clearTimeout(h);e.draw()});e.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k=function(){function f(f,e){this.radio_group="";this.typeCtr="checkbox";this.pressed=!1;a.Control.call(this,f,e);this.radio_group=this.radio_group.trim();""!==this.radio_group&&(this.typeCtr="radio");"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name.trim()+"'");this.tabindex=++this.parent.tabindex;this.containerControl=
document.createElement("div");this.checkbox=document.createElement("input");this.checkbox.setAttribute("type",this.typeCtr);""!==this.radio_group&&this.checkbox.setAttribute("name",this.radio_group);this.checkbox.internalID=this.id;this.label=document.createElement("label");this.dummyLabel=document.createElement("label");this.value=this.evaluator.eval(this.valueExpr);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.checkbox);this.containerControl.appendChild(this.dummyLabel);
this.addControlContainer(this.containerControl);this.addEvents();this.init()}a.extend(f,a.Control);f.prototype.init=function(f){h=this.evaluator;this.label.innerHTML=h.eval(this.name).toString();this.labelFontSize=a.getFieldFontSize(this.h);f=Math.max(this.w-this.h,0);this.containerControl.setAttribute("class","DescartesCheckboxContainer");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.dummyLabel.setAttribute("style",
"position:absolute; width : "+this.h+"px; height : "+this.h+"px; left: "+f+"px;");this.dummyLabel.setAttribute("for",this.id+this.typeCtr);this.checkbox.setAttribute("type",this.typeCtr);this.checkbox.setAttribute("id",this.id+this.typeCtr);this.checkbox.setAttribute("class","DescartesCheckbox");this.checkbox.setAttribute("style","width : "+this.h+"px; height : "+this.h+"px; left: "+f+"px;");this.checkbox.setAttribute("tabindex",this.tabindex);this.checkbox.checked=0!=this.value;this.label.setAttribute("class",
"DescartesCheckboxLabel");this.label.setAttribute("style","font-size:"+this.labelFontSize+"px; width: "+f+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluator.setVariable(this.id,this.value);this.update()};f.prototype.update=function(){h=this.evaluator;this.label.innerHTML=h.eval(this.name).toString();this.activeIfValue=0<h.eval(this.activeif);this.drawIfValue=0<h.eval(this.drawif);this.checkbox.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":
"none";if(!this.parent.animation.playing||document.activeElement!=this.checkbox){var a=0!==h.getVariable(this.id)?1:0;""===this.radio_group?this.pressed?(this.value=this.checkbox.checked?1:0,this.pressed=!1):(this.value=a,this.checkbox.checked=0!==this.value):(this.value=this.checkbox.checked?1:0,this.pressed&&(h.setVariable(this.radio_group,this.id),this.pressed=!1));h.setVariable(this.id,this.value)}this.updatePositionAndSize()};f.prototype.addEvents=function(){var f=this;f.checkbox.oncontextmenu=
f.label.oncontextmenu=f.dummyLabel.oncontextmenu=function(){return!1};f.label.addEventListener("touchstart",a.preventDefault);f.label.addEventListener("mousedown",a.preventDefault);f.dummyLabel.addEventListener("touchstart",a.preventDefault);f.dummyLabel.addEventListener("mousedown",a.preventDefault);f.checkbox.addEventListener("click",function(a){f.pressed=!0;f.updateAndExecAction()})};return f}();a.Checkbox=k;return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m;a.TextField=function(d,c){a.Control.call(this,d,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name.trim()+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;this.regExpDecimalSymbol=new RegExp("\\"+this.parent.decimal_symbol,
"g");this.answer&&(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?(d=this.answerPattern.indexOf("|"),this.firstAnswer=-1==d?this.answerPattern:this.answerPattern.substring(0,d)):this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(","))));this.onlyText&&(this.valueExprString.match(/^'/)&&this.valueExprString.match(/'$/)||
(this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'")),this.validateValue=function(a){a=a.toString();return"''"==a||"'"==a?"":a&&a.match(/^'/)&&a.match(/'$/)?a.substring(1,a.length-1):a},this.formatOutputValue=function(a){return a.toString()});""==name.trim()&&(name="");this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);
this.addControlContainer(this.containerControl);this.addEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(d){h=this.evaluator;var c=h.eval(this.name).toString();this.label.innerHTML=c;d||(this.value=this.validateValue(h.eval(this.valueExpr)));d=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var e=a.getTextWidth(d+"_",this.fieldFontSize+"px "+a.sansserif_font),g=parseInt(this.w/2),b=a.getTextWidth(c,this.fieldFontSize+"px "+
a.sansserif_font);this.visible||(g=this.w,e=0);g<b&&(g=b);""==c&&(g=0);this.w-g<e&&(g=this.w-e);0>g&&(g=0);c=this.w-g;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style",
"font-size: "+this.fieldFontSize+"px; width : "+c+"px; height : "+this.h+"px; left: "+g+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=d;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+g+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);
this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){h=this.evaluator;this.label.innerHTML=h.eval(this.name).toString();this.activeIfValue=0<h.eval(this.activeif);this.drawIfValue=0<h.eval(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.parent.animation.playing&&document.activeElement==this.field||(k=this.field.value,f=this.value,this.value=this.validateValue(h.getVariable(this.id)),this.field.value=
this.formatOutputValue(this.value),this.value===f&&this.field.value!=k&&(this.value=this.validateValue(k),this.field.value=this.formatOutputValue(this.value)),h.setVariable(this.id,this.value));this.updatePositionAndSize()};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";h=this.evaluator;a=a.toString().replace(this.regExpDecimalSymbol,".","g");n=a==parseFloat(a)?parseFloat(a):parseFloat(h.eval(h.parser.parse(a)));isNaN(n)&&(n=0);e=h.eval(this.min);m=h.eval(this.max);""===
e&&(e=-Infinity);""===m&&(m=Infinity);n<e&&(n=e);n>m&&(n=m);this.discrete&&(a=h.eval(this.incr),n=0===a?0:a*Math.round(n/a));return n=parseFloat(parseFloat(n).toFixed(h.eval(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluate&&(this.ok=this.evaluateAnswer()),
this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())};a.TextField.prototype.evaluateAnswer=function(){return a.esCorrecto(this.answer,this.value,this.evaluator,this.answer)};a.TextField.prototype.getFirstAnswer=function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.eval(this.firstAnswer):""};a.TextField.prototype.addEvents=function(){var d=this;d.field.oncontextmenu=d.label.oncontextmenu=function(){return!1};
d.label.addEventListener("touchstart",a.preventDefault);d.label.addEventListener("mousedown",a.preventDefault);this.field.addEventListener("blur",function(a){d.evaluator.eval(d.drawIf)&&d.changeValue(d.field.value,!0)});this.field.addEventListener("keydown",function(a){d.activeIfValue&&13==a.keyCode&&d.changeValue(d.field.value,!0)});d.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.abs,k,f,n,e,m,d,c,r,g,b;a.Menu=function(b,c){function l(a){g.options=a.split(",");g.menuOptions=[];g.strValue=[];a=0;for(var b=g.options.length;a<b;a++){var c=g.customSplit(g.options[a]);1==c.length?(g.menuOptions.push(c[0]),g.strValue.push(a.toString())):2==c.length&&(g.menuOptions.push(c[0]),""==c[1]?g.strValue.push(a.toString()):g.strValue.push(c[1]))}a=0;for(b=g.menuOptions.length;a<b;a++)g.menuOptions[a].match(/^\[/)&&g.menuOptions[a].match(/\]$/)?
g.menuOptions[a]=k.parse(g.menuOptions[a].substring(1,g.menuOptions[a].length-1)):g.menuOptions[a]=k.parse("'"+g.menuOptions[a]+"'");a=0;for(b=g.strValue.length;a<b;a++)g.strValue[a].match(/^\[/)&&g.strValue[a].match(/\]$/)?g.strValue[a]=k.parse(g.strValue[a].substring(1,g.strValue[a].length-1)):g.strValue[a]=k.parse(g.strValue[a]);for(;g.select.firstChild;)g.select.removeChild(g.select.firstChild);a=0;for(b=g.menuOptions.length;a<b;a++)c=document.createElement("option"),c.innerHTML=f.eval(g.menuOptions[a]),
g.select.appendChild(c);return 0}this.options="";a.Control.call(this,b,c);k=this.parser;f=this.evaluator;this.ok=0;this.tabindex=++this.parent.tabindex;this.answer&&(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answer=parseInt(this.answer.split(",")[0].replace("[",""))||0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+
"'");var g=this;this.evaluator.setFunction(this.id+".setOptions",l);this.containerControl=document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");this.field=document.createElement("input");l(this.options);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.addEvents();this.init()};a.extend(a.Menu,
a.Control);a.Menu.prototype.init=function(b){f=this.evaluator;var c=f.eval(this.name).toString();this.label.innerHTML=c;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var g=0,l=0;this.value=b?this.value:f.eval(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var d=0,e=this.menuOptions.length;d<e;d++)b=a.getTextWidth(f.eval(this.menuOptions[d]).toString(),this.fieldFontSize+"px "+a.sansserif_font),b>g&&(g=b,l=d);g+=25;b=a.getTextWidth(this.formatOutputValue(f.eval(this.strValue[l])),
this.fieldFontSize+"px "+a.sansserif_font)+7;l=a.getTextWidth(c,this.fieldFontSize+"px "+a.sansserif_font)+10;""==c&&(l=0);this.visible||(b=0);for(c=this.w-b-l;c<g&&0<l;)l--,c++;for(;c<g&&0<b;)b--,c++;for(;l+c+b+1<this.w;)c++,b++;g=l;d=g+c;b=this.w-d;e=this.formatOutputValue(f.eval(this.strValue[this.indexValue]));this.containerControl.setAttribute("class","DescartesMenuContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+
"px; z-index:"+this.zIndex+";");this.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width:"+l+"px; height:"+this.h+"px; line-height:"+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_menuField");this.field.value=e;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width: "+b+"px; height: "+this.h+"px; left:"+d+"px;");
this.field.setAttribute("tabindex",this.tabindex);this.select.setAttribute("id",this.id+"_menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align:left; font-size:"+this.fieldFontSize+"px; width: "+c+"px; height: "+this.h+"px; left: "+g+"px;");this.select.setAttribute("tabindex",this.tabindex);this.select.selectedIndex=this.indexValue;f.setVariable(this.id,parseFloat(e.replace(this.parent.decimal_symbol,".")));this.update()};a.Menu.prototype.update=
function(){f=this.evaluator;this.activeIfValue=0<f.eval(this.activeif);this.drawIfValue=0<f.eval(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");if(!this.parent.animation.playing||document.activeElement!=this.select){this.label.innerHTML=f.eval(this.name).toString();for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=
f.eval(this.menuOptions[a]);this.value=f.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatOutputValue(this.value);f.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))}this.ok=this.value==this.answer?1:0;this.evaluator.setVariable(this.id+".ok",this.ok);this.updatePositionAndSize()};a.Menu.prototype.customSplit=function(a){d=!1;c="";r=0;for(g=-1;r<a.length;){b=a.charAt(r);if("["===b&&-1===g){if(d||""!=c)c+="\u00a6";
g++}else"["===b?g++:"]"===b&&0===g?(d=!0,g--):"]"==a.charAt(r)&&(g=0>g?g:g-1);c+=a.charAt(r);r++}return c.split("\u00a6")};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));n=-1;e=Infinity;for(var b=0,c=this.strValue.length;b<c;b++)m=h(a-parseFloat(this.evaluator.eval(this.strValue[b]))),m<=e&&(e=m,n=b);return n};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};
a.Menu.prototype.addEvents=function(){var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};b.label.addEventListener("touchstart",a.preventDefault);b.label.addEventListener("mousedown",a.preventDefault);this.select.addEventListener("change",function(a){b.value=b.evaluator.eval(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.eval(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())});b.field.addEventListener("click",function(a){this.focus()})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,k,f,n,e,m,d,c,r,g,b,l,w,q,u,x,p,v,y;a.Scrollbar=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?"h":"v";this.container=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");
this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollHandler=document.createElement("div");this.label=document.createElement("label");this.container.appendChild(this.canvas);this.container.appendChild(this.label);this.container.appendChild(this.divUp);this.container.appendChild(this.divDown);this.container.appendChild(this.field);this.container.appendChild(this.scrollHandler);this.addControlContainer(this.container);this.addEvents();this.init()};a.extend(a.Scrollbar,
a.Control);a.Scrollbar.prototype.init=function(){k=this.evaluator;0==k.eval(this.decimals)?this.incr=1:this.incr=(k.eval(this.max)-k.eval(this.min))/100;this.value=this.validateValue(k.eval(this.valueExpr));n=this.formatOutputValue(this.value);e=this.evaluator.eval(this.expresion);this.x=e[0][0];this.y=e[0][1];4==e[0].length&&(this.w=e[0][2],this.h=e[0][3]);this.orientation=this.w>=this.h?"h":"v";this.initScroll(n);this.changeScrollPositionFromValue();this.prePos=this.pos;k.setVariable(this.id,this.value)};
a.Scrollbar.prototype.initScroll=function(b){f=this;k=f.evaluator;y=k.eval(f.name).toString();f.label.innerHTML=y;var c="v"===f.orientation?parseInt(19+5*(f.h-100)/100):f.h;f.fieldFontSize="v"===f.orientation?c-parseInt(f.h/20)-1:2!==f.parent.version?a.getFieldFontSize(c):10;var g=a.getTextWidth(b+"_",f.fieldFontSize+"px "+a.sansserif_font),l=f.parent.getSpaceById(f.spaceID).h;f.labelHeight=""==y?0:c;f.fieldHeight=""==f.visible?0:c;if("v"===f.orientation)f.canvasWidth=f.w,f.canvasHeight=f.h-f.labelHeight-
f.fieldHeight,18<=f.canvasHeight+f.y-l&&(f.canvasHeight=l),g=f.fieldHeight,c=g+f.canvasHeight,f.canvasX=0,f.canvasY=f.fieldHeight,f.labelWidth=f.w,f.labelY=c,f.upWidth=f.downW=f.w,f.upHeight=f.downH=15,f.upX=0,f.upY=f.fieldHeight,f.downX=0,f.downY=c-f.downH,f.fieldWidth=f.w,f.fieldX=0,f.scrollHandlerW=f.w,f.scrollHandlerH=parseInt((f.canvasHeight-f.upHeight-f.downH-f.labelHeight-f.fieldHeight)/10),f.scrollHandlerH=15>f.scrollHandlerH?15:f.scrollHandlerH,f.limInf=c-f.downH-f.scrollHandlerH,f.limSup=
g+f.downH;else{c=a.getTextWidth(y,f.fieldFontSize+"px "+a.sansserif_font)+10;f.labelWidth=c;f.fieldWidth=g;""==y&&(f.labelWidth=0);f.visible||(f.fieldWidth=0);for(c=f.w-f.fieldWidth-f.labelWidth;58>c&&0<f.labelWidth;)f.labelWidth--,c++;for(;58>c&&0<f.fieldWidth;)f.fieldWidth--,c++;g=f.labelWidth;l=g+c;f.fieldWidth=f.w-l;f.canvasWidth=c;f.canvasHeight=f.h;f.canvasX=f.labelWidth;f.canvasY=0;f.fieldX=f.canvasWidth+f.labelWidth;f.labelHeight=f.h;f.labelY=0;f.upWidth=f.downW=15;f.upHeight=f.downH=f.h;
f.upX=l-f.downW;f.upY=0;f.downX=f.labelWidth;f.downY=0;f.scrollHandlerW=parseInt((f.canvasWidth-f.upWidth-f.downW)/10);f.scrollHandlerW=15>f.scrollHandlerW?15:f.scrollHandlerW;f.scrollHandlerH=f.h;f.limInf=g+f.downW;f.limSup=g+f.canvasWidth-f.downW-f.scrollHandlerW}f.container.setAttribute("class","DescartesScrollbarContainer");f.container.setAttribute("id",f.id);f.container.setAttribute("style","width: "+f.w+"px; height: "+f.h+"px; left: "+f.x+"px; top: "+f.y+"px; z-index: "+f.zIndex+";");f.canvas.setAttribute("width",
f.w+"px");f.canvas.setAttribute("height",f.h+"px");f.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");f.ctx=f.canvas.getContext("2d");f.ctx.imageSmoothingEnabled=!1;f.divUp.setAttribute("class","DescartesCatcher up");f.divUp.setAttribute("style","width : "+f.upWidth+"px; height : "+f.upHeight+"px; left: "+f.upX+"px; top: "+f.upY+"px;");f.divDown.setAttribute("class","DescartesCatcher down");f.divDown.setAttribute("style","width : "+f.downW+"px; height : "+f.downH+"px; left: "+
f.downX+"px; top: "+f.downY+"px;");f.scrollHandler.setAttribute("class","DescartesCatcher manipulator");f.scrollHandler.setAttribute("style","width : "+f.scrollHandlerW+"px; height : "+f.scrollHandlerH+"px;");f.scrollHandler.style.top=("v"===f.orientation?f.limInf:0)+"px";f.scrollHandler.style.left=("v"===f.orientation?0:f.limInf)+"px";f.field.setAttribute("type","text");f.field.setAttribute("id",f.id+"scrollbar");f.field.setAttribute("class","DescartesScrollbarField");f.field.setAttribute("style",
"font-size: "+f.fieldFontSize+"px; width : "+f.fieldWidth+"px; height : "+f.fieldHeight+"px; left: "+f.fieldX+"px; top: 0px;");f.field.value=b;0===f.fieldHeight&&(f.field.style.display="none");f.label.setAttribute("class","DescartesScrollbarLabel");f.label.setAttribute("style","font-size:"+f.fieldFontSize+"px; width: "+f.labelWidth+"px; height: "+f.labelHeight+"px; line-height: "+f.labelHeight+"px; left: 0px; top:"+f.labelY+"px;")};a.Scrollbar.prototype.update=function(){k=this.evaluator;this.label.innerHTML=
k.eval(this.name).toString();0==k.eval(this.decimals)?this.incr=1:this.incr=(k.eval(this.max)-k.eval(this.min))/100;this.activeIfValue=0<k.eval(this.activeif);this.drawIfValue=0<k.eval(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.container.style.display="block",this.draw()):this.container.style.display="none";this.updatePositionAndSize();var a=this.validateValue(k.getVariable(this.id));a==this.value||0<Math.abs(a-this.value)&&1E-9>Math.abs(a-this.value)||(this.value=
a,this.changeScrollPositionFromValue(),this.prePos=this.pos);this.value=a;this.field.value=this.formatOutputValue(this.value);k.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){f=this;m=f.ctx;c=h(this.w);d=h(this.h);m.fillStyle="#e0e4e8";m.fillRect(0,0,c,d);m.strokeStyle="#7a8a99";f.down&&(m.fillStyle="#ccdcec",m.fillRect(f.downX+.5,f.downY+.5,f.downW,f.downH-1));m.strokeRect(f.downX+.5,f.downY+.5,f.downW,f.downH-1);f.up&&(m.fillStyle="#ccdcec",m.fillRect(f.upX+.5,f.upY-.5,f.upWidth,
f.upHeight+1));m.strokeRect(f.upX+.5,f.upY-.5,f.upWidth,f.upHeight+1);r=4;m.fillStyle="black";m.beginPath();"h"===f.orientation?(m.moveTo(f.downX+r,f.downH/2),m.lineTo(f.downX+f.downW-r,r),m.lineTo(f.downX+f.downW-r,f.downH-r),m.moveTo(f.upX+f.upWidth-r,f.downH/2),m.lineTo(f.upX+r,r),m.lineTo(f.upX+r,f.downH-r),m.fill(),f.activeIfValue&&(g=h(f.pos),m.fillStyle="#ccdcec",m.fillRect(g+.5,0,h(f.scrollHandlerW),d),m.strokeStyle="#6382bf",m.strokeRect(g+.5,0,h(f.scrollHandlerW),d),b=h(f.scrollHandlerW/
2),m.beginPath(),m.moveTo(g+b+.5-2,3),m.lineTo(g+b+.5-2,d-3),m.moveTo(g+b+.5,3),m.lineTo(g+b+.5,d-3),m.moveTo(g+b+.5+2,3),m.lineTo(g+b+.5+2,d-3),m.stroke())):(m.moveTo(f.downX+f.downW/2,f.downY+f.downH-r),m.lineTo(f.downX+r,f.downY+r),m.lineTo(f.downX+f.downW-r,f.downY+r),m.moveTo(f.upX+f.upWidth/2,f.upY+r),m.lineTo(f.upX+r,f.upY+f.upHeight-r),m.lineTo(f.upX+f.upWidth-r,f.upY+f.upHeight-r),m.fill(),f.activeIfValue&&(g=h(f.pos),m.fillStyle="#ccdcec",m.fillRect(0,g+.5,c,h(f.scrollHandlerH)),m.strokeStyle=
"#6382bf",m.strokeRect(0,g+.5,c,h(f.scrollHandlerH)),b=h(f.scrollHandlerH/2),m.beginPath(),m.moveTo(3,g+b+.5-2),m.lineTo(c-3,g+b+.5-2),m.moveTo(3,g+b+.5),m.lineTo(c-3,g+b+.5),m.moveTo(3,g+b+.5+2),m.lineTo(c-3,g+b+.5+2),m.stroke()));m.strokeRect(.5,.5,c-1,d-1);f.activeIfValue||(m.fillStyle="rgba(240,240,240,"+160/255+")",m.fillRect(0,0,c,d.h))};a.Scrollbar.prototype.validateValue=function(a){k=this.evaluator;l=a.toString();l=parseFloat(l.replace(this.parent.decimal_symbol,"."));isNaN(l)&&(l=0);this.minimo=
k.eval(this.min);l<this.minimo&&(this.value=null,l=this.minimo);this.maximo=k.eval(this.max);l>this.maximo&&(this.value=null,l=this.maximo);w=this.incr;l=0!=w?l*w/w:0;this.fixed&&(l=parseFloat(parseFloat(l).toFixed(k.eval(this.decimals))));return l};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(){r=(this.evaluator.eval(this.max)-
this.evaluator.eval(this.min))/10;"h"==this.orientation?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+r):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+r)};a.Scrollbar.prototype.decrease10=function(){r=(this.evaluator.eval(this.max)-this.evaluator.eval(this.min))/10;"h"==this.orientation?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-r):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-r)};a.Scrollbar.prototype.changeValue=
function(a){this.activeIfValue&&(q=this.validateValue(a),q!=this.value&&(this.value=q,this.field.value=this.formatOutputValue(q),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){k=this.evaluator;u=this.limInf;x=this.limSup;p=k.eval(this.min);v=k.eval(this.max);w=this.incr;q=h((this.pos-u)*(v-p)/(x-u)/w)*w+p;q!=this.value&&(this.value=q,this.field.value=
this.formatOutputValue(q),k.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){k=this.evaluator;u=this.limInf;x=this.limSup;p=k.eval(this.min);v=k.eval(this.max);w=this.incr;this.pos=(this.value-p)*(x-u)/(v-p)+u;"h"==this.orientation?this.scrollHandler.style.left=this.pos+"px":this.scrollHandler.style.top=this.pos+"px"};a.Scrollbar.prototype.addEvents=function(){function b(c,g,
l,d){a.clearTimeout(x);(m.up||m.down||m.canvasClick)&&1E-7<Math.abs(m.value-d)&&(g.call(m),c=l?c:30,x=a.setTimeout(function(){b(c,g,!1,d)},c))}function c(c){c.preventDefault();m.whichBtn=a.whichBtn(c);"L"==m.whichBtn&&m.activeIfValue&&(m.clickPos=a.getCursorPosition(c,m.container),m.canvasClick=!0,"h"==m.orientation?m.clickPos.x<m.prePos?b(350,m.decrease10,!0,m.minimo):b(350,m.increase10,!0,m.maximo):m.clickPos.y<m.prePos?b(350,m.increase10,!0,m.maximo):b(350,m.decrease10,!0,m.minimo))}function g(b){m.canvasClick=
!1;a.clearTimeout(x)}function l(b){1==m.canvasClick&&(m.clickPos=a.getCursorPosition(b,m.container),b.preventDefault())}function d(a){m.scrollClick=!1;m.prePos=m.pos;window.removeEventListener("mouseup",d,!1);window.removeEventListener("mousemove",f,!1);a.preventDefault()}function e(a){m.scrollClick=!1;m.prePos=m.pos;window.removeEventListener("touchend",e,!1);window.removeEventListener("touchmove",f,!1);a.preventDefault()}function f(b){var c=a.getCursorPosition(b,m.container);"h"==m.orientation?
(m.pos=m.prePos-(m.initPos.x-c.x),m.pos<m.limInf&&(m.pos=m.limInf),m.pos>m.limSup&&(m.pos=m.limSup),m.scrollHandler.setAttribute("style","background-color:rgba(255,255,255,0);cursor:pointer;position:absolute;width:"+m.scrollHandlerW+"px;height:"+m.h+"px;left:"+m.pos+"px;top:0;")):(m.pos=m.prePos-(m.initPos.y-c.y),m.pos>m.limInf&&(m.pos=m.limInf),m.pos<m.limSup&&(m.pos=m.limSup),m.scrollHandler.setAttribute("style","background-color:rgba(255,255,255,0);cursor:pointer;position:absolute;width:"+m.w+
"px;height:"+m.scrollHandlerH+"px;left:0;top:"+m.pos+"px;"));m.changeValueForScrollMovement();b.preventDefault()}function h(c){c.preventDefault();m.whichBtn=a.whichBtn(c);"L"==m.whichBtn&&m.activeIfValue&&(m.up=!0,b(350,m.increase,!0,m.maximo))}function k(c){c.preventDefault();m.whichBtn=a.whichBtn(c);"L"==m.whichBtn&&m.activeIfValue&&(m.down=!0,b(350,m.decrease,!0,m.minimo))}function q(b){m.down=!1;a.clearTimeout(x);b.preventDefault()}function n(b){m.up=!1;a.clearTimeout(x);m.draw()}function u(b){m.down=
!1;a.clearTimeout(x);m.draw()}var m=this,x;m.canvas.oncontextmenu=m.divUp.oncontextmenu=m.divDown.oncontextmenu=m.label.oncontextmenu=m.field.oncontextmenu=m.scrollHandler.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&m.changeValue(m.field.value)});this.canvas.addEventListener("touchstart",c);this.canvas.addEventListener("mousedown",c);this.divDown.addEventListener("mouseout",q);window.addEventListener("touchend",g);window.addEventListener("mouseup",
g);this.canvas.addEventListener("touchmove",l);this.canvas.addEventListener("mousemove",l);this.scrollHandler.addEventListener("touchstart",function(b){m.activeIfValue&&(m.scrollClick=!0,m.initPos=a.getCursorPosition(b,m.container),window.addEventListener("touchend",e),window.addEventListener("touchmove",f),b.preventDefault())});this.scrollHandler.addEventListener("mousedown",function(b){m.activeIfValue&&(m.scrollClick=!0,m.initPos=a.getCursorPosition(b,m.container),window.addEventListener("mouseup",
d),window.addEventListener("mousemove",f),b.preventDefault())});this.divUp.addEventListener("touchstart",h);this.divUp.addEventListener("mousedown",h);this.divDown.addEventListener("touchstart",k);this.divDown.addEventListener("mousedown",k);this.divUp.addEventListener("mouseout",function(b){m.up=!1;a.clearTimeout(x);b.preventDefault()});this.divDown.addEventListener("mouseout",q);window.addEventListener("touchend",n);window.addEventListener("mouseup",n);window.addEventListener("touchend",u);window.addEventListener("mouseup",
u)};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h;a.Audio=function(f,h){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,f,h);var e=this;f=e.evaluator.eval(e.expresion);4==f[0].length?(e.w=f[0][2],e.h=f[0][3]):(e.w=200,e.h=28);e.audio=e.parent.getAudio(e.file);e.oldFile=e.file;"]"===e.file.charAt(e.file.length-1)&&(e.file=e.evaluator.parser.parse(e.file.substring(1,e.file.length-1)));e.autoplay&&(e.audio.setAttribute("autoplay","autoplay"),e.audio.play());e.loop&&e.audio.setAttribute("loop",
"loop");e.controls&&e.audio.setAttribute("controls","controls");e.audio.setAttribute("style","position: absolute; width: "+e.w+"px; left: "+e.x+"px; top: "+e.y+"px; z-index: "+e.zIndex+";");e.addControlContainer(e.audio);e.evaluator.setFunction(e.id+".play",function(){try{e.audio.play()}catch(m){}return 0});e.evaluator.setFunction(e.id+".pause",function(){try{e.audio.pause()}catch(m){}return 0});e.evaluator.setFunction(e.id+".stop",function(){try{e.audio.pause(),e.audio.currentTime=0}catch(m){}return 0});
e.evaluator.setFunction(e.id+".currentTime",function(a){try{e.audio.currentTime=parseFloat(a)}catch(d){}return 0});e.audio.addEventListener("timeupdate",function(a){e.evaluator.setVariable(e.id+".currentTime",e.audio.currentTime)})};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";this.audio.style.top=this.y+"px";this.update()};var k;a.Audio.prototype.update=function(){h=this.evaluator;"string"!==typeof this.file&&(this.tmpFile=h.eval(this.file),this.oldFile!==
this.tmpFile&&(this.oldFile=this.audio.src=this.tmpFile));(k=0<h.eval(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",k!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=k;this.updatePositionAndSize()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h;a.Video=function(f,k){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,f,k);var e=this;h=e.evaluator;f=e.evaluator.eval(e.expresion);4==f[0].length?(e.w=f[0][2],e.h=f[0][3]):(e.w=null,e.h=null);f=e.file;k=f.lastIndexOf(".");-1!=k&&(f=e.file.substring(0,k));e.video=document.createElement("video");e.autoplay&&e.video.setAttribute("autoplay","autoplay");e.loop&&e.video.setAttribute("loop","loop");e.controls&&e.video.setAttribute("controls",
"controls");e.video.setAttribute("poster",f+".png");e.w&&(e.video.setAttribute("width",e.w),e.video.setAttribute("height",e.h));e.video.setAttribute("style","position:absolute; overflow:hidden; left:"+e.x+"px; top:"+e.y+"px; outline:none; background:rgba(0,0,0,0);");e.video.canPlayType("video/mp4")&&(k=document.createElement("source"),k.setAttribute("src",f+".mp4"),e.video.appendChild(k));e.video.canPlayType("video/ogg")&&(k=document.createElement("source"),k.setAttribute("src",f+".ogg"),k.setAttribute("type",
"video/ogg"),e.video.appendChild(k),k=document.createElement("source"),k.setAttribute("src",f+".ogv"),k.setAttribute("type","video/ogg"),e.video.appendChild(k));e.video.canPlayType("video/webm")&&(k=document.createElement("source"),k.setAttribute("src",f+".webm"),k.setAttribute("type","video/webm"),e.video.appendChild(k));e.addControlContainer(e.video);e.evaluator.setFunction(e.id+".play",function(){try{e.video.play()}catch(m){}return 0});e.evaluator.setFunction(e.id+".pause",function(){try{e.video.pause()}catch(m){}return 0});
e.evaluator.setFunction(e.id+".stop",function(){try{e.video.pause(),e.video.currentTime=0}catch(m){}return 0});e.evaluator.setFunction(e.id+".currentTime",function(a){try{e.video.currentTime=parseFloat(a)}catch(d){}return 0});e.video.addEventListener("timeupdate",function(a){e.evaluator.setVariable(e.id+".currentTime",e.video.currentTime)})};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};var k;a.Video.prototype.update=
function(){h=this.evaluator;(k=0<h.eval(this.drawif))?this.video.style.display="block":(this.video.style.display="none",k!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=k;this.updatePositionAndSize()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f;a.TextArea=function(f,e){this.font_family="Monospaced";this.style=",PLAIN,";this.font_size=12;a.Control.call(this,f,e);typeof("number"!==this.font_size)&&(this.font_size=this.evaluator.eval(this.font_size));this.font=this.font_family+this.style+this.font_size;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 h=this.parent.lessonParser.parseText(this.answer)}this.containerControl=
document.createElement("div");this.textArea=document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=
void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?this.rawText:this.text.toHTML();h&&"simpleText"!==h.type&&(this.answer=this.text.hasFormula?"":h.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();var d=this,c,k,g;this.evaluator.setFunction(this.id+".insertAtCursor",function(a){(c=window.getSelection())&&c.getRangeAt&&c.rangeCount&&(g=document.createTextNode(a),k=c.getRangeAt(0),k.deleteContents(),k.insertNode(g),k.setStart(g,g.length),k.setEnd(g,
g.length),c.removeAllRanges(),c.addRange(k),d.textArea.focus());return 0});this.evaluator.setFunction(this.id+".update",function(){d.update()});this.addEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){k=this.answer?28:4;h=this.evaluator;var f=this.text.match(/<span/)?this.text:this.text.replace(/\\n/g,"<br/>");this.containerControl.setAttribute("class","DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+
this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=0<h.eval(this.drawif)?"block":"none";this.containerControl.setAttribute("spellcheck","false");this.textArea.setAttribute("class","DescartesTextAreaContainer");this.textArea.setAttribute("style","padding: 5px; width: "+(this.w-4)+"px; height: "+(this.h-k)+"px; left: 2px; top: 2px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";line-height:"+this.font_size+
"px;");this.textArea.setAttribute("contenteditable","true");this.textArea.innerHTML=f;this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-k)+"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 f=document.createElement("canvas");f.setAttribute("width",20);f.setAttribute("height",16);var e=f.getContext("2d");e.imageSmoothingEnabled=!1;this.canvas=f;this.ctx=e;this.createGradient(20,16);e.lineWidth=1;e.fillStyle="white";e.fillRect(0,0,20,16);e.fillStyle=this.linearGradient;e.fillRect(0,0,20,16);a.drawLine(e,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(e,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(e,
1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=f.toDataURL();e.fillStyle="white";e.fillRect(0,0,20,16);e.fillStyle=this.linearGradient;e.fillRect(0,0,20,16);a.drawLine(e,0,0,0,14,"gray");a.drawLine(e,0,0,19,0,"gray");e.fillStyle="rgba(0, 0, 0,"+24/255+")";e.fillRect(0,0,this.w,this.h);this.imagePush=f.toDataURL()};a.TextArea.prototype.update=function(){h=this.evaluator;this.activeIfValue=0<h.eval(this.activeif);this.drawIfValue=0<h.eval(this.drawif);h.getVariable(this.id)!==this.oldValue&&(this.textArea.innerText=
(h.getVariable(this.id)||"").replace(/\\n/g,"\n"));f=this.textArea.innerText||"";f="\n"===f.charAt(f.length-1)?f.substring(0,f.length-1):f;f=f.replace(/\n/g,"\\n").replace(/\s/g," ");h.setVariable(this.id,f);this.oldFieldValue=f;this.oldValue=h.getVariable(this.id);this.activeCover.style.display=this.activeIfValue?"none":"block";this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize()};a.TextArea.prototype.addEvents=function(){function a(a){a.preventDefault();
e.showButton.style.backgroundImage="url("+e.imageUnPush+")"}var e=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();e.showAnswer=!e.showAnswer;e.textAreaAnswer.style.display=e.showAnswer?"block":"none";e.showButton.childNodes[0].childNodes[0].textContent=e.showAnswer?"T":"S";e.showButton.style.backgroundImage="url("+e.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a);this.textArea.addEventListener("blur",function(){var a=
window.getSelection();e.cursorInd=a.focusOffset})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=2*Math.PI,k,f,n,e,m,d,c,r,g,b;a.GraphicControl=function(b,c){f=b.evaluator.parser;this.text=this.spaceID="";this.size=f.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,c);this.font=a.convertFont(this.font);if(this.constraintExpr){this.constraint=f.parse(this.constraintExpr);"(expr)"==this.constraint.type&&(this.constraint=f.parse(this.constraintExpr.substring(1,
this.constraintExpr.length-1)));if("compOperator"==this.constraint.type){c=this.constraint.childs[0];var g=this.constraint.childs[1];"identifier"!=c.type||"y"!=c.value||g.contains("y")?"identifier"!=c.type||"x"!=c.value||g.contains("x")?this.newt=new a.R2Newton(this.evaluator,this.constraint):(this.constVar="y",this.noConstVar="x",this.evalConst=this.evalConstXoY,this.constraint=g):(this.constVar="x",this.noConstVar="y",this.evalConst=this.evalConstXoY,this.constraint=g)}else this.constraint=null;
r=new a.R2(0,0)}this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);this.addEvents();this.xStr=this.id+".x";this.yStr=this.id+".y";this.activoStr=this.id+".activo";this.activeStr=this.id+".active";""!==
this.space.id&&2!==b.version?(this.mxStr=this.space.id+".mouse_x",this.myStr=this.space.id+".mouse_y",this.mclickedStr=this.space.id+".mouse_clicked",this.mclicizquierdoStr=this.space.id+".clic_izquierdo"):(this.mxStr="mouse_x",this.myStr="mouse_y",this.mclickedStr="mouse_clicked",this.mclicizquierdoStr="clic_izquierdo");this.init()};a.GraphicControl.prototype.init=function(){k=this.evaluator;g=a.hasTouchSupport;var b=k.eval(this.expresion);this.x=b[0][0];this.y=b[0][1];k.setVariable(this.xStr,this.x);
k.setVariable(this.yStr,this.y);this.mouseCacher.setAttribute("style","cursor:pointer;background-color:rgba(255,255,255,0);z-index:"+this.zIndex+";");""==this.imageSrc||this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.width=2*k.eval(this.size),this.height=2*k.eval(this.size),this._w=g&&48>this.width?48:this.width,this._h=g&&48>this.height?48:this.height,this.mouseCacher.style.borderRadius=parseInt(Math.min(this._w,this._h)/2)+"px"):(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,
this.height=this.image.height,this._w=Math.max(this.width,32),this._h=Math.max(this.height,32));this.mouseCacher.style.width=this._w+"px";this.mouseCacher.style.height=this._h+"px";this.mouseCacher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCacher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";k.setVariable(this.activoStr,0);k.setVariable(this.activeStr,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=function(){k=this.evaluator;
this.activeIfValue=0<k.eval(this.activeif);this.drawIfValue=0<k.eval(this.drawif);this.x=k.getVariable(this.xStr);this.y=k.getVariable(this.yStr);n=this.space.getAbsoluteX(this.x);e=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=this.activeIfValue?"block":"none";this.mouseCacher.style.left=parseInt(n-this._w/2)+"px";this.mouseCacher.style.top=parseInt(e-this._h/2)+"px";this.constraint&&this.evalConst();this.draw()};a.GraphicControl.prototype.draw=function(){k=this.evaluator;this.drawIfValue&&
(d=this.ctx,c=this.space.backgroundCtx,n=parseInt(this.space.getAbsoluteX(this.x))+.5,e=parseInt(this.space.getAbsoluteY(this.y))+.5,""!=this.text&&this.drawText(n,e),this.image.ready?(this.image.complete&&!this.setImage&&d.drawImage(this.image,parseInt(n-this.image.width/2),parseInt(e-this.image.height/2)),this.trace&&(c.save(),c.translate(n,e),c.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),c.beginPath(),c.arc(0,0,1,0,h,!1),c.restore(),c.lineWidth=1,c.strokeStyle=this.trace.getColor(),
c.stroke())):(d.beginPath(),d.arc(n,e,parseInt(this.width/2),0,h,!1),d.fillStyle=this.colorInt.getColor(),d.fill(),d.lineWidth=1,d.strokeStyle=this.color.getColor(),d.stroke(),this.active&&(d.strokeStyle=this.colorInt.borderColor(),d.beginPath(),d.arc(n,e,parseInt(this.width/2)-2,0,h,!1),d.stroke()),this.trace&&(c.strokeStyle=this.trace.getColor(),c.beginPath(),c.arc(n,e,parseInt(this.width/2),0,h,!1),c.stroke())))};a.GraphicControl.prototype.evalConst=function(){r.set(this.x,this.y);m=this.newt.findZero(r,
1/this.space.scale,!0);this.x=m.x;this.y=m.y;this.evaluator.setVariable(this.xStr,this.x);this.evaluator.setVariable(this.yStr,this.y)};a.GraphicControl.prototype.evalConstXoY=function(){k=this.evaluator;b=k.getVariable(this.constVar);k.setVariable(this.constVar,this[this.constVar]);this[this.noConstVar]=k.eval(this.constraint);k.setVariable(this.xStr,this.x);k.setVariable(this.yStr,this.y);k.setVariable(this.constVar,b)};a.GraphicControl.prototype.drawText=function(a,b){d=this.ctx;k=this.evaluator;
"simpleText"==this.text.type?(d.fillStyle=this.color.getColor(),d.font=this.font,d.textBaseline="alphabetic",d.fillText(this.text.toString(k.eval(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))):(d.fillStyle=this.color.getColor(),d.strokeStyle=this.color.getColor(),d.textBaseline="alphabetic",this.text.draw(d,parseInt(a+1+this.width/2),parseInt(b-1-this.height/2),this.decimals,this.fixed,"start",!0,this.color.getColor()))};a.GraphicControl.prototype.getContainer=
function(){for(var a=this.parent.spaces,b,c=0,g=a.length;c<g;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.activoStr,0);this.evaluator.setVariable(this.activeStr,0);this.evaluator.setVariable(this.mclicizquierdoStr,0)};a.GraphicControl.prototype.addEvents=
function(){function b(g){document.body.focus();g.preventDefault();g.stopPropagation();d.evaluator.setVariable(d.mclickedStr,1);d.evaluator.setVariable(d.mclicizquierdoStr,1);if(d.activeIfValue||d.active)d.click=!1,window.removeEventListener("mouseup",b,!1),window.removeEventListener("mousemove",c,!1),window.removeEventListener("touchend",b,!1),window.removeEventListener("touchmove",c,!1),e=a.getCursorPosition(g,d.container),d.posX=d.prePos.x-(d.posAnte.x-e.x),d.posY=d.prePos.y-(d.posAnte.y-e.y),d.evaluator.setVariable(d.xStr,
d.space.getRelativeX(d.posX)),d.evaluator.setVariable(d.yStr,d.space.getRelativeY(d.posY)),d.evaluator.setVariable(d.mxStr,d.space.getRelativeX(e.x)),d.evaluator.setVariable(d.myStr,d.space.getRelativeY(e.y)),d.parent.updateControls(),d.parent.update(),d.mouseCacher.style.left=d.space.getAbsoluteX(d.x)-d._w/2+"px",d.mouseCacher.style.top=d.space.getAbsoluteY(d.y)-d._h/2+"px";d.parent.deactivateGraphiControls()}function c(b){b.preventDefault();d.evaluator.setVariable(d.mclickedStr,0);d.evaluator.setVariable(d.mclicizquierdoStr,
0);e=a.getCursorPosition(b,d.container);d.posX=d.prePos.x-(d.posAnte.x-e.x);d.posY=d.prePos.y-(d.posAnte.y-e.y);d.evaluator.setVariable(d.xStr,d.space.getRelativeX(d.posX));d.evaluator.setVariable(d.yStr,d.space.getRelativeY(d.posY));d.evaluator.setVariable(d.mxStr,d.space.getRelativeX(e.x));d.evaluator.setVariable(d.myStr,d.space.getRelativeY(e.y));20<Date.now()-g&&(d.parent.updateControls(),d.parent.update(),g=Date.now())}var g=0,d=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=
function(){return!1};this.mouseCacher.addEventListener("touchstart",function(g){document.body.focus();g.preventDefault();d.activeIfValue&&(d.parent.deactivateGraphiControls(),d.click=d.active=!0,d.evaluator.setVariable(d.activoStr,1),d.evaluator.setVariable(d.activeStr,1),d.evaluator.setVariable(d.mclickedStr,0),d.evaluator.setVariable(d.mclicizquierdoStr,0),d.posAnte=a.getCursorPosition(g,d.container),d.prePos={x:d.space.getAbsoluteX(d.x),y:d.space.getAbsoluteY(d.y)},d.evaluator.setVariable(d.mxStr,
d.space.getRelativeX(d.posAnte.x)),d.evaluator.setVariable(d.myStr,d.space.getRelativeY(d.posAnte.y)),d.parent.update(),window.addEventListener("touchend",b),window.addEventListener("touchmove",c))});this.mouseCacher.addEventListener("mousedown",function(g){document.body.focus();g.preventDefault();d.whichBtn=a.whichBtn(g);"L"==d.whichBtn&&d.activeIfValue&&d.over&&(d.parent.deactivateGraphiControls(),d.click=d.active=!0,d.evaluator.setVariable(d.activoStr,1),d.evaluator.setVariable(d.activeStr,1),
d.evaluator.setVariable(d.mclickedStr,0),d.evaluator.setVariable(d.mclicizquierdoStr,0),d.posAnte=a.getCursorPosition(g,d.container),d.prePos={x:d.space.getAbsoluteX(d.x),y:d.space.getAbsoluteY(d.y)},d.evaluator.setVariable(d.mxStr,d.space.getRelativeX(d.posAnte.x)),d.evaluator.setVariable(d.myStr,d.space.getRelativeY(d.posAnte.y)),d.parent.update(),window.addEventListener("mouseup",b),window.addEventListener("mousemove",c))});this.mouseCacher.addEventListener("mouseover",function(a){d.over=!0});
this.mouseCacher.addEventListener("mouseout",function(a){d.over=!1;d.click=!1});var e};return a}(descartesJS||{});
descartesJS=function(a,h){var k,f,n,e,m,d,c,r,g,b;if(a.loadLib)return a;var l,w,q,u,x,p,v,y,A=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,C,I,G,K,E,z,F,L,N,M,B,D,J,H,P,O,Q,U,T,S,R;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,g=a.length;c<g;c++)switch(q=a[c][0],u=a[c][1],w=h[q],w){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[w]=
parseInt(u);break;case "about":case "config":case "init":case "clear":b[w]="true"===h[u];break;default:console.log("Propiedad de botones no identificada: <"+q+"> valor: <"+u+">")}return b};a.LessonParser.prototype.parseSpace=function(b){x={};b=this.split(b);for(var c=0,g=b.length;c<g;c++)switch(q=b[c][0],u=b[c][1],w=h[q],a.DEBUG.paramName=q,a.DEBUG.objectName="Space",w){case "id":a.DEBUG.idName=u;case "x_axis":case "y_axis":case "type":case "cID":case "file":case "info":x[w]=u;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":case "resizable":x[w]=
"true"===h[u];break;case "bg_display":case "render":x[w]=h[u];break;case "net":case "net10":case "axes":case "text":x[w]=""!=u?"false"===h[u]?"":new a.Color(u,this.parent.evaluator):"";break;case "O.x":x.OxExpr=u;break;case "O.y":x.OyExpr=u;break;case "image":x.imageSrc=u;break;case "x":l=u;"%"===l[l.length-1]?(x.xPercentExpr=l.trim(),l=(this.parent.container.width*parseFloat(l)/100).toString()):l=u;x.xExpr=this.parser.parse(l);break;case "y":l=u;"%"===l[l.length-1]?(x.yPercentExpr=l.trim(),l=(this.parent.container.height*
parseFloat(l)/100).toString()):l=u;x.yExpr=this.parser.parse(l);break;case "width":l=u.trim();x.wModExpr=l;"%"===l[l.length-1]?(x.wExpr=l,l=this.parent.container.width*parseFloat(l)/100):(l=parseFloat(u),l!=u&&(l=this.parent.container.width,x._w_=u.trim()));x.w=l;break;case "height":l=u.trim();x.hModExpr=l;"%"===l[l.length-1]?(x.hExpr=l,l=this.parent.container.height*parseFloat(l)/100):(l=parseFloat(u),l!=u&&(l=this.parent.container.height,x._h_=u.trim()));x.h=l;break;case "drawif":""!=u&&(x.drawif=
this.parser.parse(u));break;case "scale":l=parseFloat(u);isNaN(l)&&(l=48);x.scale=l;break;case "background":x.background=new a.Color(u,this.parent.evaluator);break;default:console.log("Propiedad del espacio no identificada: <"+q+"> valor: <"+u+">")}switch(x.type){case "R2":return new a.Space2D(this.parent,x);case "R3":return new a.Space3D(this.parent,x);case "AP":return new a.SpaceAP(this.parent,x);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,x);default:return new a.Space2D(this.parent,
x)}};a.LessonParser.prototype.parseControl=function(b){p={type:"numeric"};b=this.split(b);for(var c=0,g=b.length;c<g;c++)switch(q=b[c][0],u=b[c][1],w=h[q],a.DEBUG.paramName=q,a.DEBUG.objectName="Control",w){case "id":a.DEBUG.idName=u;case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "font_family":case "file":case "answer":case "cssClass":case "radio_group":case "info":p[w]=u;break;case "gui":case "region":case "action":case "msg_pos":case "poster":case "text_align":case "image_align":p[w]=
h[u];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":case "flat":p[w]="true"===h[u];break;case "color":case "colorInt":case "trace":p[w]=new a.Color(u,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":""!==u&&(p[w]=this.parser.parse(u));break;case "constraint":p.constraintExpr=u;break;case "image":p.imageSrc=u;break;case "space":p.spaceID=u;break;
case "type":p.type=h[u.trim()];break;case "expresion":p.expresion=this.parser.parse(u.replace(")(",","));break;case "borderColor":p[w]="false"===h[u]?"":u;break;case "bold":"false"!=h[u]&&(p.bold="bold");break;case "italics":"false"!=h[u]&&(p.italics="italic");break;case "underlined":"false"!=h[u]&&(p.underlined=!0);break;case "value":var d=u.replace(/&squot;/g,"'");d.match(/^\|/)&&(d="'"+d.substring(1),d.match(/\|$/)&&(d=d.substring(0,d.length-1)+"'"));p.valueExpr=this.parser.parse(d);p.valueExprString=
d;break;case "incr":0!=u&&(p.incr=this.parser.parse(u));break;case "exponentialif":p.exponentialif=parseFloat(u);break;case "text":p.rawText=u;d=this.parseText(u);for(var l=0,e=d.length;l<e;l++)d[l]=this.parser.parse(d[l],!1);p.text=d;break;default:l=q.indexOf("."),d=h[q.substring(0,l)],l=h[q.substring(l+1)],"parameter"===d&&"font"===l?p.parameterFont=u:"Explanation"===d&&"font"===l?p.ExplanationFont=u:"tooltip"===d&&"font"===l?p.tooltipFont=u:console.log("Propiedad de control no identificada: <"+
q+"> valor: <"+u+">")}if("numeric"===p.type)switch(p.gui){case "spinner":return new a.Spinner(this.parent,p);case "button":return new a.Button(this.parent,p);case "textfield":return new a.TextField(this.parent,p);case "menu":return new a.Menu(this.parent,p);case "scrollbar":return new a.Scrollbar(this.parent,p);default:return new a.Spinner(this.parent,p)}else{if("video"===p.type)return new a.Video(this.parent,p);if("audio"===p.type)return new a.Audio(this.parent,p);if("graphic"===p.type)return new a.GraphicControl(this.parent,
p);if("text"===p.type)return new a.TextArea(this.parent,p);if("checkbox"===p.type)return new a.Checkbox(this.parent,p)}};a.LessonParser.prototype.parseGraphic=function(b,c,g,d){v={rotateExp:d,parameter:"t"};b=this.split(b);d=0;for(var l=b.length;d<l;d++)if(q=b[d][0],u=b[d][1],w=h[q],a.DEBUG.paramName=q,a.DEBUG.objectName="Graphic",""!=u)switch(w){case "type":a.DEBUG.idName=u;case "align":case "anchor":case "lineDash":v[w]=h[u];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":case "bold":case "italics":case "underlined":v[w]=
"true"===h[u];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":v[w]="false"===h[u]?"":new a.Color(u,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "font_family":case "name":case "init":case "end":v[w]=u;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "border_radius":case "opacity":case "inirot":case "inipos":case "range":case "font_size":""!=u&&(v[w]=this.parser.parse(u));
break;case "space":v.spaceID=u;break;case "expresion":""!=u&&("macro"!=v.type?(v.expresion=this.parser.parse(u),v.expresionString=u):v.expresion=u);break;case "text":v.text=u;break;case "file":var e=u.replace(/&squot;/g,"'");"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));e.match(A)&&(e="'"+e+"'");v.file=this.parser.parse(e);break;case "border":""!=u&&"false"!=h[u]&&(v.border=new a.Color(u,this.parent.evaluator));break;default:if(void 0!=v.family&&q.substring(0,v.family.length+
1)===v.family+".")switch(h[q.substring(v.family.length+1)]){case "interval":""!=u&&(v.family_interval=this.parser.parse(u));break;case "steps":""!=u&&(v.family_steps=this.parser.parse(u))}else if(void 0!=v.parameter&&q.match(v.parameter+"."))switch(v.parameter!==q.substring(0,q.indexOf(v.parameter)+v.parameter.length)&&(v.parameter=q.substring(0,q.indexOf(v.parameter)+v.parameter.length)),h[q.substring(v.parameter.length+1)]){case "interval":""!=u&&(v.parameter_interval=this.parser.parse(u));break;
case "steps":""!=u&&(v.parameter_steps=this.parser.parse(u))}else console.log("Propiedad del grafico no identificada: <"+q+"> valor: <"+u+">")}c&&(v.abs_coord=c);g&&(v.background=g);switch(v.type){case "text":return new a.Text(this.parent,v);case "image":return new a.Image(this.parent,v);case "point":return new a.Point(this.parent,v);case "polygon":return new a.Polygon(this.parent,v);case "arc":return new a.Arc(this.parent,v);case "segment":return new a.Segment(this.parent,v);case "arrow":return new a.Arrow(this.parent,
v);case "macro":return new a.Macro(this.parent,v);case "curve":return new a.Curve(this.parent,v);case "equation":return new a.Equation(this.parent,v);case "sequence":return new a.Sequence(this.parent,v);case "rectangle":return new a.Rectangle(this.parent,v);case "fill":return new a.Fill(this.parent,v)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,g,d){v={rotateExp:d,parameter:"t"};b=this.split(b);c=0;for(g=b.length;c<g;c++)switch(q=b[c][0],u=b[c][1],w=h[q],a.DEBUG.paramName=q,a.DEBUG.objectName=
"Graphic3D",w){case "type":a.DEBUG.idName=u;case "model":case "lineDash":v[w]=h[u];break;case "fill":v[w]="false"===h[u]?"":new a.Color(u,this.parent.evaluator);break;case "background":case "fixed":case "split":case "bold":case "italics":case "underlined":v[w]="true"===h[u];break;case "edges":"false"===h[u]?v[w]="":("true"===h[u]&&(u="808080"),v[w]=new a.Color(u,this.parent.evaluator));break;case "color":case "backcolor":v[w]=new a.Color(u,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "R":case "r":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":case "offset_angle":case "offset_dist":case "font_size":""!=
u&&(v[w]=this.parser.parse(u));break;case "family":case "parameter":case "font":case "font_family":case "name":case "inirot":case "endrot":case "info":v[w]=u;break;case "space":v.spaceID=u;break;case "expresion":"macro"!=v.type&&"curve"!=v.type&&"surface"!=v.type?(v.expresion=this.parser.parse(u),v.expresionString=u):v.expresion=u.replace(/\\n/g,";");break;case "text":v.text=u;break;case "file":d=u.replace(/&squot;/g,"'");"["===d.charAt(0)&&"]"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));
d.match(/./)&&(d="'"+d+"'");v.file=this.parser.parse(d);break;default:void 0!==v.family&&q.substring(0,v.family.length+1)===v.family+"."?"interval"===h[q.substring(v.family.length+1)]?""!=u&&(v.family_interval=this.parser.parse(u)):""!=u&&(v.family_steps=this.parser.parse(u)):console.log("Propiedad del grafico 3D no identificada: <"+q+"> valor: <"+u+">")}switch(v.type){case "point":return new a.Point3D(this.parent,v);case "segment":return new a.Segment3D(this.parent,v);case "polygon":return new a.Polygon3D(this.parent,
v);case "curve":return new a.Curve3D(this.parent,v);case "triangle":return new a.Triangle3D(this.parent,v);case "face":return new a.Face3D(this.parent,v);case "polireg":return new a.Polireg3D(this.parent,v);case "surface":return new a.Surface3D(this.parent,v);case "text":return new a.Text3D(this.parent,v);case "cube":case "box":case "tetrahedron":case "octahedron":case "sphere":case "dodecahedron":case "icosahedron":case "ellipsoid":case "cone":case "cylinder":case "torus":case "mesh":return new a.OtherGeometry(this.parent,
v);case "macro":return new a.Macro3D(this.parent,v)}};a.LessonParser.prototype.parseAuxiliar=function(b){y={};b=this.split(b);for(var c=0,g=b.length;c<g;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(g=b.length;c<g;c++)switch(q=b[c][0],u=b[c][1],w=h[q],a.DEBUG.paramName=q,a.DEBUG.objectName="Auxiliar",w){case "info":case "code":y[w]=u;break;case "id":a.DEBUG.idName=u;case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":y[w]=
u.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":y[w]="true"===h[u];break;case "size":case "rows":case "columns":case "x":case "y":case "width":case "height":y[w]=this.parser.parse(u);break;case "evaluate":case "execution":case "msg_pos":case "action":case "type":y[w]=h[u];break;case "doc":break;default:var d=q.indexOf("."),l=h[q.substring(0,d)];d=h[q.substring(d+1)];"parameter"===l&&"font"===d?y.parameterFont=
u:console.log("Propiedad del auxiliar no identificada: <"+q+"> valor: <"+u+">")}y.sequence?y.type="sequence":y.constant?y.type="constant":y.algorithm&&y.evaluate?y.type="algorithm":y.array&&!y.matrix&&")"!=y.id.charAt(y.id.length-1)?y.type="vector":y.matrix&&")"!=y.id.charAt(y.id.length-1)?y.type="matrix":y.event&&")"!=y.id.charAt(y.id.length-1)?y.type="event":"library"===y.type?y.type="library":"jsfun"===y.type?y.type="jsfun":")"===y.id.charAt(y.id.length-1)?y.type="function":y.type="variable";a.DEBUG.typeName=
y.type;switch(y.type){case "sequence":new a.Function(this.parent,y);break;case "constant":b=new a.Constant(this.parent,y);y.evaluate&&"always"===y.evaluate&&this.parent.auxiliaries.push(b);break;case "algorithm":this.parent.auxiliaries.push(new a.Algorithm(this.parent,y));break;case "vector":b=new a.Vector(this.parent,y);y.evaluate&&"always"===y.evaluate&&this.parent.auxiliaries.push(b);break;case "matrix":b=new a.Matrix(this.parent,y);y.evaluate&&"always"===y.evaluate&&this.parent.auxiliaries.push(b);
break;case "event":this.parent.events.push(new a.Event(this.parent,y));break;case "library":new a.Library(this.parent,y);break;case "function":new a.Function(this.parent,y);break;case "variable":new a.Variable(this.parent,y);break;case "jsfun":new a.JsFunction(this.parent,y)}};a.LessonParser.prototype.parseAction=function(b){C=b.action;I=b.parent;G=b.parameter;if(C)switch(C){case "message":return new a.Message(I,G);case "calculate":return new a.Calculate(I,G);case "openURL":return new a.OpenURL(I,
G);case "openScene":return new a.OpenScene(I,G);case "about":return new a.About(I,G);case "config":return new a.Config(I,G);case "init":return new a.Init(I,G);case "clear":return new a.Clear(I,G);case "animate":return new a.Animate(I,G);case "initAnimation":return new a.InitAnimation(I,G);case "playAudio":return new a.PlayAudio(I,G);default:console.log("Accion no soportada: <"+C+">")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var g=
0,d=b.length;g<d;g++)switch(q=b[g][0],u=b[g][1],w=h[q],w){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[w]=u.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[w]="true"===h[u];break;default:console.log("Propiedad de la animacion no identificada: <"+q+">  <"+u+">")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(l,h){l=this.split(l);f=k="";n=0;e="#536891";m="white";d="left";c="";r="SansSerif,BOLD,20";
g="SansSerif,PLAIN,18";b=void 0;for(var x=0,p=l.length;x<p;x++)switch(q=l[x][0],u=l[x][1],q){case "title":k=u;break;case "subtitle":f=u;break;case "subtitlines":n=u;break;case "bgcolor":""!=u&&(e=(new a.Color(u,this.parent.evaluator)).getColor());break;case "fgcolor":""!=u&&(m=(new a.Color(u,this.parent.evaluator)).getColor());break;case "align":""!=u&&(d=u);break;case "titleimage":c=u;break;case "titlefont":r=""!=u?a.convertFont(u):a.convertFont(r);break;case "subtitlefont":g=""!=u?a.convertFont(u):
a.convertFont(g);break;default:console.log("Propiedad de la pleca no identificada: <"+q+">  <"+u+">")}if(""===k&&""===f)return document.createElement("div");M=g.substring(0,g.indexOf("px"));M=M.substring(M.lastIndexOf(" "));""!=c&&(B=this.parent.getImage(c),D=B.height);b=document.createElement("div");b.setAttribute("id","descartesPleca");D?(b.setAttribute("style","position:absolute;left:0;top:0;text-align:"+d+";width:"+h+"px;height:"+D+"px;background:"+e+";color:"+m+";padding-top:8px;padding-bottom:8px;padding-left:15px;padding-right:15px;margin:0;overflow:hidden;z-index:1;"),
B.setAttribute("style","position: absolute;left:0;top:0;z-index:-1;width:100%;height:100%;"),b.appendChild(B)):b.setAttribute("style","position:absolute;left:0;top:0;text-align:"+d+";width:"+h+"px;background:"+e+";color:"+m+";padding-top:12px;padding-bottom:12px;padding-left:15px;padding-right:15px;margin:0;z-index:100;");J=document.createElement("div");J.setAttribute("style","padding:0;margin:0;font:"+r+";overflow:hidden;white-space:nowrap;");J.innerHTML=k;H=document.createElement("div");if(1===
parseInt(n)){T=0;P=document.createElement("div");P.innerHTML=f;document.body.appendChild(P);Q=M;do Q-=T,P.setAttribute("style","padding:0;margin:0;font:"+g+";font-size:"+Q+"px;width:"+(h-30)+"px;line-height:"+Q+"px;"),O=P.offsetHeight,U=O/Q,T=1;while(1<U&&8<Q);document.body.removeChild(P);H.setAttribute("style","padding:0;margin:0;font:"+g+";font-size:"+Q+"px;line-height:1em;overflow:hidden;white-space:nowrap;")}else H.setAttribute("style","padding:0;margin:0;font:"+g+";line-height:1em;");H.innerHTML=
f;b.appendChild(J);b.appendChild(H);b.imageHeight=D;return b};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");K=[];E=z=L=0;for(F=N=!1;E<a.length;)" "!==a.charAt(E)||F||E++," "===a.charAt(E)||F||(F=!0,L=E),"="!==a.charAt(E)||"'"!==a.charAt(E+1)||N||(N=!0,K[z]=[a.substring(L,E)],L=E+2,E+=2),N&&"'"===a.charAt(E)&&(F=N=!1,K[z].push(a.substring(L,E)),z++),"="!==a.charAt(E)||"'"===a.charAt(E+1)||N||(K[z]=[a.substring(L,E)],L=E+1,E++,S=a.substring(E).indexOf("="),
-1===S?R=S=a.length:(S+=E,R=a.substring(E,S).lastIndexOf(" "),R=-1===R?a.length:R+E),K[z].push(a.substring(L,R)),z++,F=!1,E=R),E++;return K};a.LessonParser.prototype.parseText=function(b){b=b||"";return b.match(/^\{\\rtf1/)?this.RTFparser.parse(b.substring(10)):new a.SimpleText(this.parent,b)};return a}(descartesJS||{},babel);
descartesJS=function(a){function h(a,b){if(0==b)return 1;if(0>b)return NaN;if(0<=a||Math.floor(b)===b)return Math.pow(a,b);if(0>a){var c=1/b,g=Math.floor(c);if(g===c&&1===g%2)return-Math.pow(-a,b)}return NaN}function k(a,b){u=[];u.type="matrix";u.rows=a;u.cols=b;p=0;for(v=b;p<v;p++){b=[];x=0;for(y=a;x<y;x++)b.push(0);u[p]=b}return u}function f(a,b){w=a.rows;q=a.cols;u=k(w,q);var c;for(p=0;p<w;p++)for(x=0;x<q;x++){for(v=c=0;v<q;v++)c+=a[v][p]*b[x][v];u[x][p]=c}return u}function n(a,b,c){for(var g=
k(c.length-1,c.length-1),d=0,l=g.length;d<l;d++)for(var e=0;e<l;e++)g[d][e]=d<a?e<b?c[d][e]:c[d][e+1]:d<b?c[d+1][e]:c[d+1][e+1];return g}function e(a){if(1<a.cols){for(var b=0,c=1,g=0,d=a.cols;g<d;g++)b+=c*a[0][g]*e(n(0,g,a)),c=-c;return b}return a[0][0]}if(a.loadLib)return a;var m,d={},c=Math.floor,r,g,b,l;a.fullDecimals=!1;a.Node=function(a,b){this.sep="";this.type=a;this.value=b;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null===this.parent?this:this.parent.getRoot()};
a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){r=this.childs.length-1;lastChild=this.childs[r];lastChild.parent=null;this.childs[r]=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="-",b=new a.Node("compOperator",
"=="),l=new a.Node("number","0"),b.addChild(this),b.addChild(l),g=this.getRoot(),g.setAllEvalFun(),g):this};a.Node.prototype.setAllEvalFun=function(){this.setEvalFun();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvalFun()};a.Node.prototype.setEvalFun=function(){if("number"===this.type)this.evaluate=function(a){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(a){return this.value.replace(/\\u0027/g,"'")};else if("identifier"===this.type&&0===this.childs.length)if("rnd"==
this.value)this.evaluate=function(a){return Math.random()};else{var b;this.evaluate=function(a,c){b=a.variables[this.value];if("object"===typeof b&&void 0==b.length)return b.evaluate(a);void 0==b&&(c||a.matrices[this.value]?b=a.matrices[this.value]:a.vectors[this.value]&&(b=a.vectors[this.value]));return void 0!==b?b:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1===this.childs[0].childs.length){var g;this.evaluate=function(a){J=this.childs[0].childs[0].evaluate(a);
try{return g=a.vectors[this.value][0>J?0:c(J)],void 0!==g?g:0}catch(P){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var l,r;this.evaluate=function(a){l=this.childs[0].childs[0].evaluate(a);r=this.childs[0].childs[1].evaluate(a);try{return g=a.matrices[this.value][0>l?0:c(l)][0>r?0:c(r)],void 0!==g?g:0}catch(P){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var v,y,z;this.evaluate=function(a){v=
[];for(var b=0,c=this.childs[0].childs.length;b<c;b++)v[b]=this.childs[0].childs[b].evaluate(a);if("_Eval_"===this.value){m=0<v.length?v[0]:0;if("number"==typeof m)return"NaN";m.match(",")&&parseFloat(m.replace(",","."))==m.replace(",",".")&&(m=m.replace(",","."));if(void 0==d[m]){y=m.match(/:=/g)?!0:!1;if(m.match(";")){var g=!1,l=[],e=0;b=0;for(c=m.length;b<c;b++){var f=m.charAt(b);"'"===f&&(g=!g);g||";"!==f||(l.push(m.substring(e,b)),e=b+1)}l.push(m.substring(e));m="("+l.join(")(")+")"}d[m]=a.parser.parse(m,
y)}z=a.eval(d[m]);return void 0!=z?z:NaN}return a.functions[this.value].apply(a,v)}}else if("operator"===this.type)"+"===this.value?this.evaluate=function(b){var c=this.childs[0].evaluate(b,!0);b=this.childs[1].evaluate(b,!0);if("matrix"!==c.type||"matrix"!==b.type)return"number"==typeof c&&"string"==typeof b?c=a.removeNeedlessDecimals(c.toString()):"string"==typeof c&&"number"==typeof b&&(b=a.removeNeedlessDecimals(b.toString())),c+b;w=c.rows;q=c.cols;u=k(w,q);for(p=0;p<w;p++)for(x=0;x<q;x++)u[x][p]=
c[x][p]+b[x][p];return u}:"-"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||"matrix"!==a.type)return b-a;w=b.rows;q=b.cols;u=k(w,q);for(p=0;p<w;p++)for(x=0;x<q;x++)u[x][p]=b[x][p]-a[x][p];return u}:"*"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);return"matrix"!==b.type||"matrix"!==a.type?b*a:f(b,a)}:"/"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,
!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||"matrix"!==a.type)return b/a;var c=k(a.length,a.length),g=e(a);if(0===g)a=0;else{g=1/g;if(1<a.length)for(var d=0,l=a.length;d<l;d++){var h=g;for(var q=0;q<l;q++)c[q][d]=h*e(n(d,q,a)),h=-h;g=-g}else c[0][0]=g;a=c}b=0===a?k(b.rows,b.cols):f(b,a);return b}:"%"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a);a=this.childs[1].evaluate(a);return b-c(b/a)*a}:"^"===this.value&&(this.evaluate=function(a){var b=this.childs[0].evaluate(a);
a=this.childs[1].evaluate(a);return 0<=a?h(b,a):1/h(b,-a)});else if("compOperator"===this.type)"<"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)<this.childs[1].evaluate(a)?1:0}:"<="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)<=this.childs[1].evaluate(a)?1:0}:">"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)>this.childs[1].evaluate(a)?1:0}:">="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)>=
this.childs[1].evaluate(a)?1:0}:"=="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)===this.childs[1].evaluate(a)?1:0}:"!="===this.value&&(this.evaluate=function(a){return this.childs[0].evaluate(a)!==this.childs[1].evaluate(a)?1:0});else if("boolOperator"===this.type)"&"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)?1:this.childs[1].evaluate(a)?
1:0}:"!"===this.value&&(this.evaluate=function(a){return this.childs[0].evaluate(a)?0:1});else if("conditional"===this.type)this.evaluate=function(a){return 0<this.childs[0].evaluate(a)?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate="sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};else if("parentheses"===this.type)this.evaluate=function(a,b){return this.childs[0].evaluate(a,b)};else if("(expr)"===
this.type||"[expr]"===this.type)this.evaluate=function(a){var b=this.childs.length,c=[];if(1===b&&1===this.childs[0].childs.length&&"(expr)"===this.type)c=this.childs[0].childs[0].evaluate(a);else for(var g=0;g<b;g++){var d=[];for(var l=0,e=this.childs[g].childs.length;l<e;l++)d.push(this.childs[g].childs[l].evaluate(a));c[g]=d}return c};else if("asign"===this.type){var F,L,N,M,B=this.childs[0],D=this.childs[1];var J=B.childs[0]?B.childs[0].childs:null;this.evaluate=1===B.childs.length&&"square_bracket"===
B.childs[0].type&&1===J.length?function(a){F=J[0].evaluate(a);F=0>F?0:c(F);M=D.evaluate(a);return a.vectors[B.value][F]=M}:1===B.childs.length&&"square_bracket"===B.childs[0].type&&2===J.length?function(a){L=J[0].evaluate(a);N=J[1].evaluate(a);L=0>L?0:c(L);N=0>N?0:c(N);a.matrices[B.value][L]||(a.matrices[B.value][L]=[]);M=D.evaluate(a);return a.matrices[B.value][L][N]=M}:function(a){M=D.evaluate(a);return M.type?a.matrices[B.value]=M:"object"!==typeof a.variables[B.value]?a.variables[B.value]=M:0}}};
var w,q,u,x,p,v,y;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var b=0,c=this.childs.length;b<c;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r,g=/^\s+/,b=/^[a-zA-Z_\u00C0-\u021B\u0391-\u03C9]+[a-zA-Z_0-9\u00C0-\u021B\u0391-\u03C9]*([.]*[0-9a-zA-Z_\u00C0-\u021B\u0391-\u03C9]+[0-9]*)*/,l=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,w=/^==|^!=|^<=|^<|^>=|^>|^#/,q=/^!|^~|^&&|^&|^\|\||^\|/,u=/^=|^:=/,x=/^[\?:]/,p=/^[\+\-\*\/%\^\u2212\u00b7\u00D7\u00F7]/,v=/^\[|^\]/,y=/^\(|^\)/,A=/^,/,C=/^;/,I=/\|/g,G=/\|\*/g,K=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(z){function E(a,
b,g){k.push({type:a,value:b});m=m.slice(g);n+=g;c++;r=a}if(h=z){var F=z.indexOf("//");0<=F&&":"!==z[F-1]&&(z=z.substring(0,F));z=z.replace(/\\u(\S+) /g,function(a,b){return 39!==parseInt(b,16)?String.fromCharCode(parseInt(b,16)):a});z=z.replace(/&sup(.+);/g,"^ $1 ");z=z.replace(/&squot;/g,"'");z.match(/=\|\*/g)&&(z=z.replace(G,"'").replace(K,"'"));z.match(/=\|/g)&&(z=z.replace(I,"'"));F=z.trim();"|"==F.charAt(0)&&"|"==F.charAt(F.length-1)&&(z=F.replace(I,"'"))}k=[];f=!1;n=0;m=z;c=0;for(r="";z&&n<
z.length;)if(f=n,"'"==m[0]){for(d=1;"'"!=m[d];)if(d<m.length)d++;else{console.info(">Error, unknown symbol: ["+m+"], in the string \u300a"+h+"\u300b");return}e=m.substring(1,d);E("string",e,e.length+2)}else if(e=m.match(g))m=m.slice(e[0].length),n+=e[0].length,c++;else if(e=m.match(p))e[0]=e[0].replace(/\u00F7/g,"/").replace(/\u2212/g,"-").replace(/\u00b7/g,"*").replace(/\u00D7/g,"*"),E("operator",e[0],e[0].length);else if(e=m.match(b))"number"===r&&k.push({type:"operator",value:"*"}),E("identifier",
e[0],e[0].length);else if(e=m.match(l))E("number",e[0],e[0].length);else if(e=m.match(w))F=e[0],"#"==F&&(F="!="),E("compOperator",F,e[0].length);else if(e=m.match(q))F=e[0],"||"==F?F="|":"&&"==F?F="&":"~"==F&&(F="!"),E("boolOperator",F,e[0].length);else if((e=m.match(u))&&!m.match(/^==/))E("asign",e[0],e[0].length);else if(e=m.match(x))E("conditional",e[0],e[0].length);else if(e=m.match(v))E("square_bracket",e[0],e[0].length);else if(e=m.match(y))"("==e&&"number"===r&&k.push({type:"operator",value:"*"}),
E("parentheses",e[0],e[0].length);else if(e=m.match(A))E("separator",e[0],e[0].length);else if(178===m.charCodeAt(0))k.push({type:"operator",value:"^"}),E("number",2,1);else if(179===m.charCodeAt(0))k.push({type:"operator",value:"^"}),E("number",3,1);else if(e=m.match(C))E("final_of_expresion",e[0],e[0].length);else if(f==n){a.DEBUG.setError(a.DEBUG.EXPRESSION,h);return}return k};var E,z=/rnd|pi|e|Infinity|-Infinity|sqr|sqrt|ra\u00edz|exp|log|log10|abs|ent|sgn|ind|sin|sen|cos|tan|cot|sec|csc|sinh|senh|cosh|tanh|coth|sech|csch|asin|asen|acos|atan|min|max/;
a.Tokenizer.prototype.flatTokens=function(a,b){a=a||[];b=b||"";E="";for(var c=0,g=a.length;c<g;c++)E="string"==a[c].type?E+"&squot;"+a[c].value+"&squot;":"identifier"!=a[c].type||a[c].value.match(z)?E+a[c].value:E+b+a[c].value;return E};return a}(descartesJS||{});
descartesJS=function(a){function h(a){switch(a){case "=":return 1;case ":=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "%":return 8;case "^":return 9;default:return 9}}
function k(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,""):parseFloat(a)==a?parseFloat(a):a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")}if(a.loadLib)return a;a.reservedIds=new String("-_-rnd-pi-\u03c0-e-Infinity-isTouch-esT\u00e1ctil-screenOrientation-screenWidth-screenHeight-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-atan2-floor-ceil-round-min-max-_Trace_-_Print_-_Num_-_Stop_Audios_-esCorrecto-escorrecto-parent.set-parent.update-parent.exec-toFixed-_NumToStr_-_NumACadena_-charAt-_charAt_-_letraEn_-substring-_substring_-_subcadena_-strLength-_length_-_longitud_-indexOf-_indexOf_-\u00edndiceDe-lastIndexOf-replace-_replace_-_reemplazar_-toLowerCase-toUpperCase-_Load_-_GetValues_-_GetMatrix_-_MatrixToStr_-_StrToMatrix_-_GetVector_-_VectorToStr_-_StrToVector_-_ExecStr_-_ExecBlock_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_strWidth_-_Rojo_-_Red_-_Verde_-_Green_-_Azul_-_Blue_-DJS.typeof-");
var f=Date.now();a.Parser=function(b){this.evaluator=b;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.definitions={};this.registerDefaultValues();this.registerExternalValues&&this.registerExternalValues()};a.Parser.prototype.setDefinition=function(a,b){this.definitions[a]=b};a.Parser.prototype.getDefinition=function(a){return this.definitions[a]};a.Parser.prototype.setVariable=function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=
function(a,b){b&&(this.variables[a]=void 0!==this.variables[a]?this.variables[a]:void 0);return this.variables[a]};a.Parser.prototype.setVector=function(a,b,c){this.vectors[a][b]=c};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,b,c,g){this.matrices[a][b][c]=g};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 n,e,m,d,c,r,g,b,l,w,q,u;a.Parser.prototype.parse=function(f,k){(m=this.tokenizer.tokenize(f))||(m=[]);d=null;k=!k||!1;n=b=g=r=0;for(e=m.length;n<e;n++){l=m[n];w=l.value;q=l.type;if("identifier"===q)if(n+1<e&&"parentheses"===m[n+1].type&&"("===m[n+1].value)this.getFunction(w);else if(n+1<
e&&"square_bracket"===m[n+1].type&&"["===m[n+1].value)m[n+3]&&"square_bracket"===m[n+3].type&&"]"===m[n+3].value?this.getVector(w):this.getMatrix(w);else{var x=w.match(/(\w*)\.mouse_x|(\w*)\.mouse_y|(\w*)\.mouse_pressed|(\w*)\.mouse_clicked|(\w*)\.clic_izquierdo/);x&&(this.variables[(x[1]||x[2]||x[3]||x[4]||x[5])+".DESCARTESJS_no_fixed"]=1);this.getVariable(w,!0)}"asign"===q&&k&&":="!=w&&(q="compOperator",w="==");if("asign"===q)if(c=new a.Node(q,w),null!=d)if("identifier"===d.type)d.parent&&d.parent.replaceLastChild(c),
c.addChild(d),d=c,k=!0;else if("square_bracket"===d.type)c.addChild(d.parent),d=c,k=!0;else{c.type="compOperator";c.value="==";for(k=!0;d.parent&&h(d.parent.value)>=h(c.value);)d=d.parent;d.parent&&d.parent.replaceLastChild(c);c.addChild(d);d=c}else{console.info("Error1: en la expresion \u300a "+f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}else if("parentheses"===q&&"("===w||"square_bracket"===q&&"["===w)if(c=new a.Node(q,w),"("===w&&r++,"["===w&&g++,null===d)"("===w&&(new a.Node("(expr)",
"(expr)")).addChild(c),"["===w&&(new a.Node("[expr]","[expr]")).addChild(c),d=c;else if("operator"===d.type||"boolOperator"===d.type||"compOperator"===d.type||"conditional"===d.type||"asign"===d.type)d.addChild(c),d=c;else if("sign"===d.type)d.addChild(c),d=c;else if("parentheses"===d.type&&"("===d.value)d.addChild(c),d=c;else if("square_bracket"===d.type&&"["===d.value)d.addChild(c),d=c;else if("parentheses"===d.type&&"()"===d.value)d.parent.addChild(c),d=c;else if("square_bracket"===d.type&&"[]"===
d.value)d.parent.addChild(c),d=c;else if("identifier"===d.type)d.addChild(c),d=c;else{console.info("Error2: en la expresion \u300a "+f+" \u300b, en el token ["+n+"] {valor: "+w+", tipo: "+q+"}");break}else if("parentheses"===q&&")"===w)if(r--,null===d)console.info("Error3: en la expresion \u300a "+f+" \u300b, en el token (valor:"+w+", tipo:"+q);else{for(;d&&d.parent&&("("!=d.value||"("==d.value&&"parentheses"!=d.type);)d=d.parent;if(d&&"("===d.value)d.value="()";else break}else if("square_bracket"===
q&&"]"===w)if(g--,null===d)console.info("Error5: en la expresion \u300a "+f+" \u300b, en el token (valor:"+w+", tipo:"+q);else{for(;d&&d.parent&&("["!=d.value||"["==d.value&&"square_bracket"!=d.type);)d=d.parent;if(d&&"["===d.value)d.value="[]";else{console.info("Error6: en la expresion \u300a "+f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}}else if("number"===q||"string"===q||"identifier"===q)if(c=new a.Node(q,w),null===d)d=c;else if("operator"===d.type||"compOperator"===d.type||"boolOperator"===
d.type||"parentheses"===d.type&&"("===d.value||"square_bracket"===d.type&&"["===d.value||"sign"===d.type||"conditional"===d.type||"asign"===d.type)d.addChild(c),d=c;else{a.DEBUG.setError(a.DEBUG.EXPRESSION,f);break}else if("operator"===q||"compOperator"===q||"boolOperator"===q)if(c=new a.Node(q,w),null===d)if("-"===w||"+"===w)c.type="sign",c.value="sign"+w,d=c;else if("!"===w)d=c;else{console.info("Error8: en la expresion \u300a "+f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}else if("operator"===
d.type||"compOperator"===d.type||"boolOperator"===d.type||"asign"===d.type||"conditional"===d.type||"square_bracket"===d.type&&"["===d.value&&("-"===w||"+"===w||"!"===w)||"parentheses"===d.type&&"("===d.value&&("-"===w||"+"===w||"!"===w)){if("-"===w||"+"===w)c.type="sign",c.value="sign"+w;d.addChild(c);d=c}else if("number"===d.type||"parentheses"===d.type&&"()"===d.value||"square_bracket"===d.type&&"[]"===d.value||"string"===d.type||"identifier"===d.type||"conditional"===d.type||"asign"===d.type){for(;d.parent&&
h(d.parent.value)>=h(c.value);)d=d.parent;d.parent&&d.parent.replaceLastChild(c);c.addChild(d);d=c}else{console.info("Error9: en la expresion \u300a "+f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}else if("conditional"===q)if(c=new a.Node(q,w),null!=d)if("?"===c.value){for(b++;d.parent&&h(d.parent.value)>h(c.value);)d=d.parent;d.parent&&d.parent.replaceLastChild(c);c.addChild(d);d=c}else{for(b--;d&&d.parent&&("?"!=d.value||"?"==d.value&&"conditional"!=d.type);)d=d.parent;if(d&&"?"===
d.value)d.value="?:";else{console.info("Error10: en la expresion \u300a "+f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}}else{console.info("Error11: en la expresion \u300a "+f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}else if("separator"===q)if(null!=d)for(;d.parent&&"("!=d.value&&"["!=d.value;)d=d.parent;else{console.info("Error12: en la expresion \u300a "+f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}else{console.info("Error13: en la expresion \u300a "+
f+" \u300b, en el token {valor: "+w+", tipo: "+q+"}");break}}0<r&&a.DEBUG.setError(a.DEBUG.PARENTHESIS_CLOSING,f);0>r&&a.DEBUG.setError(a.DEBUG.PARENTHESIS_OPENING,f);0<g&&a.DEBUG.setError(a.DEBUG.BRACKET_CLOSING,f);0>g&&a.DEBUG.setError(a.DEBUG.BRACKET_OPENING,f);0!=b&&a.DEBUG.setError(a.DEBUG.INCOMPLETE_IF,f);(u=d?d.getRoot():null)&&u.setAllEvalFun();return u};a.Parser.prototype.registerDefaultValues=function(){var b=this;b.variables.rnd=Math.random;b.variables.pi=b.variables["\u03c0"]=a.returnValue(Math.PI);
b.variables.e=a.returnValue(Math.E);b.variables.Infinity=Infinity;b.variables["-Infinity"]=-Infinity;b.variables.isTouch=b.variables["esT\u00e1ctil"]=a.hasTouchSupport?1:0;Object.defineProperties(b.variables,{screenOrientation:{get:function(){return window.matchMedia("(orientation: landscape)").matches?"landscape":"portrait"}},screenWidth:{get:function(){return window.innerWidth}},screenHeight:{get:function(){return window.innerHeight}}});b.functions.sqr=function(a){return a*a};b.functions.sqrt=b.functions["ra\u00edz"]=
Math.sqrt;b.functions.exp=Math.exp;b.functions.log=Math.log;b.functions.log10=function(a){return Math.log(a)/Math.log(10)};b.functions.abs=Math.abs;b.functions.ent=Math.floor;b.functions.sgn=function(a){return 0<a?1:0>a?-1:0};b.functions.ind=function(a){return a?1:0};b.functions.sin=b.functions.sen=Math.sin;b.functions.cos=Math.cos;b.functions.tan=Math.tan;b.functions.cot=function(a){return 1/Math.tan(a)};b.functions.sec=function(a){return 1/Math.cos(a)};b.functions.csc=function(a){return 1/Math.sin(a)};
b.functions.sinh=b.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};b.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};b.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};b.functions.coth=function(a){return 1/b.functions.tanh(a)};b.functions.sech=function(a){return 1/b.functions.cosh(a)};b.functions.csch=function(a){return 1/b.functions.sinh(a)};b.functions.asin=b.functions.asen=Math.asin;b.functions.acos=Math.acos;b.functions.atan=
Math.atan;b.functions.atan2=Math.atan2;b.functions.floor=Math.floor;b.functions.ceil=Math.ceil;b.functions.round=Math.round;b.functions.min=Math.min;b.functions.max=Math.max;b.functions._Trace_=b.functions._Print_=function(){console.info.apply(console,arguments);return 0};b.functions._Num_=function(a){if("number"==typeof a)return"NaN";a=a.replace(",",".");return parseFloat(a)==a?parseFloat(a):"NaN"};b.functions._Stop_Audios_=function(){b.evaluator.parent.stopAudios()};b.functions.esCorrecto=function(c,
g,d){return a.esCorrecto(c,g,b.evaluator,d)};b.functions.escorrecto=function(c,g,d){return a.escorrecto(c,g,b.evaluator,d)};window.parent!==window&&(b.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",name:a,value:b},"*");return 0},b.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*");return 0},b.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*");return 0});b.functions.toFixed=b.functions._NumToStr_=
b.functions._NumACadena_=function(a,b){a=isNaN(parseFloat(a))?0:parseFloat(a);return a.toFixed(parseInt(b||0))};b.functions.charAt=b.functions._charAt_=b.functions._letraEn_=function(a,b){a=(a||"").toString();b=isNaN(parseInt(b))?0:parseInt(b);return a.charAt(b)};b.functions.substring=b.functions._substring_=b.functions._subcadena_=function(a,b,c){a=(a||"").toString();b=isNaN(parseInt(b))?0:parseInt(b);c=isNaN(parseInt(c))?0:parseInt(c);return 0<=b&&0<=c?a.substring(b,c):0>b&&0<=c?a.substring(c):
0>c&&0<=b?a.substring(b):""};b.functions.strLength=b.functions._length_=b.functions._longitud_=function(a){return(a||"").toString().length};b.functions.indexOf=b.functions._indexOf_=b.functions["_\u00edndiceDe_"]=function(a,b){return(a||"").toString().indexOf((b||"").toString())};b.functions.lastIndexOf=function(a,b){return(a||"").toString().lastIndexOf((b||"").toString())};b.functions.replace=b.functions._replace_=b.functions._reemplazar_=function(a,b,c){a=(a||"").toString();b=(b||"").toString();
c=(c||"").toString();for(var g=a.indexOf(b);0<=g;)a=a.substring(0,g)+c+a.substring(g+b.length),g=a.indexOf(b);return a};b.functions.toLowerCase=function(a){return(a||"").toString().toLowerCase()};b.functions.toUpperCase=function(a){return(a||"").toString().toUpperCase()};b.functions._Load_=function(b){var c="";b&&(c=(c=document.getElementById(b))&&"descartes/archivo"==c.type?c.text:a.openExternalFile(b));return c||""};b.functions._GetValues_=function(a,c){return b.functions._ExecBlock_(b.functions._Load_(a).replace(/&brvbar;/g,
String.fromCharCode("166")),c)};b.functions._GetMatrix_=function(a,c){return b.functions._StrToMatrix_(b.functions._Load_(a).replace(/&brvbar;/g,String.fromCharCode("166")),c)};b.functions._MatrixToStr_=function(c){var g=b.matrices[c];if(g){for(var d="<"+c+">\\n",l=b.getVariable(c+".columnas_usadas")||g.cols||0,e=b.getVariable(c+".filas_usadas")||g.rows||0,f,h=0;h<l;h++){for(var k=0;k<e;k++)f=g[h][k],void 0!==f&&("string"==typeof f?f="'"+f+"'":"number"==typeof f&&(f=a.removeNeedlessDecimals(f.toFixed(6))),
d+=f+(k<e-1?" \u00a6 ":""));d=d.replace(/(\u00A6 )$/g,"")+"\\n"}return d+"</"+c+">"}return""};b.functions._StrToMatrix_=function(a,c){var g=[],d=!1,l=!1;g.type="matrix";if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var e=0,f=a.length;e<f;e++)a[e].match("<"+c+">")?(l=!0,d=a[e].trim().split("<"+c+">"),2==d.length&&""!=d[1]&&g.push(d[1].split(String.fromCharCode("166")).map(k)),d=!0):(a[e].match("</"+c+">")&&(d=a[e].trim().split("</"+c+">"),2==d.length&&""!=d[0]&&g.push(d[0].split(String.fromCharCode("166")).map(k)),
d=!1,e=a.length),d&&g.push(a[e].split(String.fromCharCode("166")).map(k)));b.matrices[c]=g;b.matrices[c].rows=g&&g[0]&&g[0].length?g[0].length:0;b.matrices[c].cols=g&&g.length?g.length:0;b.setVariable(c+".filas",b.matrices[c].rows);b.setVariable(c+".columnas",b.matrices[c].cols)}return l?"OK":"ERROR"};b.functions._GetVector_=function(a,c){return b.functions._StrToVector_(b.functions._Load_(a),c)};b.functions._VectorToStr_=function(a){var c=b.vectors[a];if(c){for(var g="<"+a+">\\n",d=b.getVariable(a+
".long_usada")||c._size_||0,l,e=0;e<d;e++)l=c[e],void 0!==l?("number"==typeof l&&(l=parseFloat(l)),g+=l+"\\n"):g+="0\\n";return g+"</"+a+">"}return""};b.functions._StrToVector_=function(a,c){var g=[],d=!1,l=!1;g.type="vector";if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var e=0,f=a.length;e<f;e++)a[e].match("<"+c+">")?d=l=!0:(a[e].match("</"+c+">")&&(d=!1,e=a.length),d&&g.push(k(a[e])));g._size_=g.length;b.vectors[c]=g;b.setVariable(c+".long",g.length);b.setVariable(c+".long_usada",g.length)}return l?
"OK":"ERROR"};b.functions._ExecStr_=function(a){return b.functions._ExecBlock_(a,"")};b.functions._ExecBlock_=function(a,c){var g=[],d=""==c;if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var l=0,e=a.length;l<e;l++)a[l].match("<"+c+">")?(d=a[l].trim().split("<"+c+">"),2==d.length&&""!=d[1]&&(g=g.concat(d[1].split(String.fromCharCode("166")))),d=!0):a[l].match("</"+c+">")?(d=a[l].trim().split("</"+c+">"),2==d.length&&""!=d[0]&&(g=g.concat(d[0].split(String.fromCharCode("166")))),d=!1):d&&(g=g.concat(a[l].split(String.fromCharCode("166"))));
l=0;for(e=g.length;l<e;l++)d=g[l].split("="),d[0]=d[0].trim(),2==d.length&&""!=d[0]&&(isNaN(parseFloat(d[1]))?b.setVariable(d[0],d[1].replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")):b.setVariable(d[0],parseFloat(d[1])))}return 0};var c=document.createElement("a");c.setAttribute("target","_blank");var g,d=null;a.newBlobContent=null;b.functions._Save_=function(l,e){b.evaluator.parent.removeButtonClick();1500<Date.now()-f&&(f=Date.now(),document.body.appendChild(c),d=e.replace(/\\r/g,"").replace(/\\n/g,
"\r\n").replace(/\\q/g,"'").replace(/\\_/g,"\\"),g=new Blob(["\ufeff",d],{type:"text/plain;charset=utf-8"}),c.setAttribute("href",window.URL.createObjectURL(g)),c.setAttribute("download",l),d!=a.newBlobContent&&(c.click(),a.newBlobContent=d),document.body.removeChild(c));return 0};var l,e,h=document.createElement("input");h.setAttribute("type","file");h.addEventListener("change",function(c){l=c.target.files;e=new FileReader;e.onload=function(c){a.addExternalFileContent(l[0].name,c.target.result);
b.setVariable("DJS.fileName",l[0].name);b.setVariable("DJS.fileContent",c.target.result);b.getFunction(b._callback)&&(b.getFunction(b._callback).apply(b.evaluator,[]),b.evaluator.parent.update());h.value=""};0<l.length&&e.readAsText(l[0])});b.functions._Open_=function(a){b.evaluator.parent.removeButtonClick();1500<Date.now()-f&&(b._callback=a,h.click(),f=Date.now());return 0};b.functions._AnchoDeCadena_=b.functions._strWidth_=function(b,c,g,d){return a.getTextWidth(b,a.convertFont(c+","+g+","+d))};
b.functions._Rojo_=b.functions._Red_=function(b){return(new a.Color(b)).r/255};b.functions._Verde_=b.functions._Green_=function(b){return(new a.Color(b)).g/255};b.functions._Azul_=b.functions._Blue_=function(b){return(new a.Color(b)).b/255};b.functions["DJS.typeof"]=function(a){return a.rows?"matrix":a._size_?"vector":typeof a}};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor;a.Evaluator=function(h){this.parent=h;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices;this.definitions=this.parser.definitions};a.Evaluator.prototype.setDefinition=function(a,f){this.definitions[a]=f};a.Evaluator.prototype.getDefinition=function(a){return this.definitions[a]};a.Evaluator.prototype.setVariable=function(a,
f){this.variables[a]=f};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,f,n){f=0>f?0:h(f);this.vectors[a][f]=n};a.Evaluator.prototype.getVector=function(a,f){f=0>f?0:h(f);return this.vectors[a][f]};a.Evaluator.prototype.setMatrix=function(a,f,n,e){f=0>f?0:h(f);n=0>n?0:h(n);this.matrices[a][f][n]=e};a.Evaluator.prototype.getMatrix=function(a,f,n){f=0>f?0:h(f);n=0>n?0:h(n);return this.matrices[a][f][n]};a.Evaluator.prototype.setFunction=
function(a,f){this.functions[a]=f};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.eval=function(a){return a?a.evaluate(this):0};a.externalEvaluator=new a.Evaluator;return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r,g,b,l,w,q,u;a.TextObject=function(b,c){this.parent=b;this.evaluator=b.evaluator;this.decimals=b.decimals;this.fixed=b.fixed;this.align=b.align||"left";this.anchor=b.anchor||"a_top_left";this.decimal_symbol=b.parent.decimal_symbol;this.w=this.h=100;this.hasContent=""!==c;this.textStr=(c||"").replace(/\\{/g,"\\curlyBracketOpen ").replace(/\\}/g,"\\curlyBracketClose ").replace(/\\\[/g,"\\squareBracketOpen ").replace(/\\\]/g,"\\squareBracketClose ");
this.oldTextStr=this.oldWidth=this.oldSize=this.oldColor=this.oldPosX=this.oldPoxY=null;c.match(/^\{\\rtf1/)?(this.type="rtfNode",this.text=c,this.textNodes=(new a.RTFParser(b.evaluator)).parse(c.substring(10))):(this.descarTeXParser=new a.DescarTeXParser,this.text=this.parseSimpleText(this.textStr),this.textNodes=new a.TextNode("","textLineBlock",null,null))};a.TextObject.prototype.draw=function(a,b,c,g,d){"rtfNode"===this.type?this.drawRTF(a,b,c,g,d):this.drawText(a,b,c,g,d)};a.TextObject.prototype.drawText=
function(b,c,g,d,l){h=this.evaluator.eval(this.decimals);k=this.evaluator.eval(this.parent.width);f=this.evaluator.eval(this.parent.font_size);n=c.getColor?c.getColor():c;e=this.textToString(this.text,h,this.fixed).replace(/\\{/g,"\\curlyBracketOpen ").replace(/\\}/g,"\\curlyBracketClose ").replace(/\\\[/g,"\\squareBracketOpen ").replace(/\\\]/g,"\\squareBracketClose ");0<=e.indexOf("[")&&(e=this.textToString(this.parseSimpleText(e),h,this.fixed));if(this.oldTextStr!==e||this.oldWidth!==k||this.oldSize!==
f||this.oldColor!==n||this.oldPosX!==g||this.oldPoxY!==d)m=new a.TextStyle({size:f,family:this.parent.font_family||"arial",italic:this.parent.italics||!1,bold:this.parent.bold||!1,color:n,align:this.align,border:this.parent.border}),this.textNodes=this.descarTeXParser.parse(e,this.evaluator,m),this.textNodes.update(g,d,h,this.fixed,this.align,this.anchor,n,k);l||this.textNodes.draw(b);this.oldTextStr=e;this.oldWidth=k;this.oldSize=f;this.oldColor=n;this.oldPosX=g;this.oldPoxY=d};a.TextObject.prototype.drawRTF=
function(a,b,c,g,d){b=b.getColor?b.getColor():b;a.fillStyle=b;a.strokeStyle=b;a.textBaseline="alphabetic";this.textNodes.style.align!==this.align&&this.textNodes.propagateStyle("align",this.align);this.textNodes.update(c,g,this.evaluator.eval(this.decimals),this.fixed,this.align,this.anchor,b,this.evaluator.eval(this.parent.width));d||this.textNodes.draw(a)};a.TextObject.prototype.parseSimpleText=function(a){a=a.replace("&#x2013","\u2013").replace(/&squot;/g,"'");d=[];c="'";g=r=0;b=-1;for(q=a.length;r<
q;)l=a.charAt(r),w=a.charAt(r-1),"["===l&&"\\"===w?(d.push(a.substring(g,r-1)+"["),g=r+1):"]"===l&&"\\"===w?(d.push(a.substring(g,r-1)+"]"),g=r+1):"["===l&&-1===b?(d.push(a.substring(g,r)),g=r,b++):"["===l?b++:"]"===l&&0===b?(d.push(this.evaluator.parser.parse(a.substring(g,r+1))),g=r+1,b--):("]"==a.charAt(r)&&(b=0>b?b:b-1),c+=a.charAt(r)),r++;d.push(a.substring(g,r));return d};a.TextObject.prototype.textToString=function(b,g,d){c="";if("rtfNode"!==b.type)for(var l=0,e=b.length;l<e;l++)"string"===
typeof b[l]?c+=b[l]:(u=this.evaluator.eval(b[l])[0][0],""!==u&&("string"===typeof u?c+=u:Infinity===u?c+="Infinity":-Infinity===u?c+="-Infinity":isNaN(u)||"NaN"===u?c+="NaN":(u=parseFloat(u),u=d?u.toFixed(g):a.removeNeedlessDecimals(u.toFixed(g)),c+=u.toString().replace(".",this.decimal_symbol))));return c};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.DescarTeXTokenizer=function(){};a.DescarTeXTokenizer.prototype.tokenize=function(a){a=a.replace(/\\n/g,"\\newline ");var h=[],f=null,n=0,e=a.length;a.charAt(0);var m=!1,d=!1,c=0;newInput="";for(var r=0;r<e;r++){var g=a.charAt(r);var b=a.charAt(r+1);"\\"===g&&"$"===b&&(d=!0);"{"===g?c++:"}"===g&&(c--,d&&0===c&&(d=!1));d?"_"===g?"{"===b?newInput+="\\subindex":(newInput+="\\subindex{"+b+"}",r++):"^"===g?"{"===b?newInput+="\\superindex":(newInput+="\\superindex{"+
b+"}",r++):newInput+=g:newInput+=g}a=newInput;b=a.charAt(0);for(e=a.length;n<e;)g=b,b=a.charAt(n+1),m&&("{"===g||"["===g||"\\"===g||" "===g?(m=!1," "===g&&(f={type:"ignore"},h.push(f))):f.value+=g),m||"\\"!==g?m||"{"!==g&&"["!==g?m||"}"!==g&&"]"!==g?m||(f&&"text"===f.type?f.value+=g:f&&"ignore"===f.type?(h.pop(),f=h[h.length-1]):(f={type:"text",value:g},h.push(f))):(f={type:"close",value:g},h.push(f)):(f={type:"open",value:g},h.push(f)):(m=!0,f={type:"command",value:""},h.push(f)),n++;return h};return a}(descartesJS||
{});
descartesJS=function(a){if(a.loadLib)return a;a.DescarTeXParser=function(){this.tokenizer=new a.DescarTeXTokenizer};a.DescarTeXParser.prototype.parse=function(h,k,f){h=this.tokenizer.tokenize(h);var n=new a.TextNode("","textBlock",f,null),e=new a.TextNode("","textLineBlock",f.clone(),null);n.addChild(e);for(var m=[],d=null,c=f,r=[f],g,b,l,w=!1,q=0,u=h.length;q<u;q++)if("text"===h[q].type)if("textLineBlock"===e.nodeType)if("color_parameter"===d)b=new a.Color(h[q].value,k);else{g=h[q].value.split(" ");for(var x=
0,p=g.length;x<p;x++)""!==g[x]&&e.addChild(new a.TextNode(g[x],"text",c.clone(),null)),x+1<p&&e.addChild(new a.TextNode(" ","space",c.clone(),null))}else e.addChild(new a.TextNode(h[q].value,"text",c.clone(),null));else if("command"===h[q].type&&"curlyBracketOpen"===h[q].value)e.addChild(new a.TextNode("{","text",c.clone(),null));else if("command"===h[q].type&&"curlyBracketClose"===h[q].value)e.addChild(new a.TextNode("}","text",c.clone(),null));else if("command"===h[q].type&&"squareBracketOpen"===
h[q].value)e.addChild(new a.TextNode("[","text",c.clone(),null));else if("command"===h[q].type&&"squareBracketClose"===h[q].value)e.addChild(new a.TextNode("]","text",c.clone(),null));else if("command"===h[q].type&&"newline"===h[q].value)0===e.children.length&&e.addChild(new a.TextNode("","text",c.clone(),null)),e=new a.TextNode("","textLineBlock",f.clone(),null),n.addChild(e);else if("command"===h[q].type&&"b"===h[q].value)d="bold",m.push(d);else if("command"===h[q].type&&"i"===h[q].value)d="italic",
m.push(d);else if("command"===h[q].type&&"color"===h[q].value)d="color",m.push(d);else if("command"===h[q].type&&"c"===h[q].value)d="center",m.push(d);else if("command"===h[q].type&&"l"===h[q].value)d="left",m.push(d);else if("command"===h[q].type&&"r"===h[q].value)d="right",m.push(d);else if("command"===h[q].type&&"j"===h[q].value)d="justify",m.push(d);else if("command"===h[q].type&&"$"===h[q].value)d="formula",m.push(d),w=!0;else if("command"===h[q].type&&"sum"===h[q].value)d="sum",m.push(d);else if("command"===
h[q].type&&"int"===h[q].value)d="integral",m.push(d);else if("command"===h[q].type&&"lim"===h[q].value)d="limit",m.push(d);else if("command"===h[q].type&&"sqrt"===h[q].value)d="radical",m.push(d);else if("command"===h[q].type&&"subindex"===h[q].value)d="subIndex",m.push(d);else if("command"===h[q].type&&"superindex"===h[q].value)d="superIndex",m.push(d);else if("command"===h[q].type&&"frac"===h[q].value)d="numerator",m.push(d);else if("open"===h[q].type&&"{"===h[q].value&&null!==d)"bold"===d||"italic"===
d?(newStyle=c.clone(),newStyle[d]=!0,r.push(newStyle),c=newStyle):"color"===d?d="color_parameter":"color_text"===d?(newStyle=c.clone(),newStyle.color=b,r.push(newStyle),c=newStyle):"center"===d||"left"===d||"right"===d||"justify"===d?(newStyle=c.clone(),newStyle.align=d,r.push(newStyle),c=newStyle,e=new a.TextNode("","textLineBlock",c.clone(),null),n.addChild(e)):"formula"===d?(newStyle=c.clone(),newStyle.italic=!0,r.push(newStyle),c=newStyle,l=new a.TextNode("","formula",c.clone(),null),e.addChild(l),
e=l):"subIndex"===d||"superIndex"===d?w?(newStyle=c.clone(),r.push(newStyle),c=newStyle,l=new a.TextNode("",d,c.clone(),null),e.addChild(l),e=l):e.addChild(new a.TextNode("subIndex"===d?"_":"^","text",c.clone(),null)):"radical"===d?w&&(l=new a.TextNode("","radical",c.clone(),null),e.addChild(l),e=l,newStyle=c.clone(),r.push(newStyle),c=newStyle,l=new a.TextNode("","index",c.clone(),null),e.addChild(l),e=l,d="index"):"index"===d?w&&(r.pop(),c=r[r.length-1],l=new a.TextNode("","radicand",c.clone(),
null),e.addChild(l),e=l,d="radicand"):"sum"===d||"integral"===d||"limit"===d?w&&(l=new a.TextNode("",d,c.clone(),null),e.addChild(l),e=l,newStyle=c.clone(),r.push(newStyle),c=newStyle,l=new a.TextNode("","from",c.clone(),null),e.addChild(l),e=l,d="from"):"from"===d?w&&(l=new a.TextNode("","to",c.clone(),null),e.addChild(l),e=l,d="to"):"to"===d?w&&(r.pop(),c=r[r.length-1],l=new a.TextNode("","what",c.clone(),null),e.addChild(l),e=l,d="what"):"numerator"===d?w&&(l=new a.TextNode("","fraction",c.clone(),
null),e.addChild(l),e=l,newStyle=c.clone(),r.push(newStyle),c=newStyle,l=new a.TextNode("","numerator",c.clone(),null),e.addChild(l),e=l,d="numerator"):"denominator"===d&&(l=new a.TextNode("",d,c.clone(),null),e.addChild(l),e=l);else if("close"===h[q].type&&"}"===h[q].value&&null!==d){if("bold"===d||"italic"===d||"color_text"===d||"color"===d)r.pop(),c=r[r.length-1],m.pop(),d=m[m.length-1];else if("color_parameter"===d)d="color_text";else if("center"===d||"left"===d||"right"===d||"justify"===d)r.pop(),
c=r[r.length-1],m.pop(),d=m[m.length-1],h[q+1]&&"command"===h[q+1].type&&"newline"===h[q+1].value?e=n:(e=new a.TextNode("","textLineBlock",c.clone(),null),n.addChild(e));"formula"===e.nodeType?(w=!1,r.pop(),c=r[r.length-1],m.pop(),d=m[m.length-1],e=e.parent):"subIndex"===e.nodeType||"superIndex"===e.nodeType?w&&(r.pop(),c=r[r.length-1],m.pop(),d=m[m.length-1],e=e.parent):"index"===e.nodeType?e=e.parent:"radicand"===e.nodeType?(m.pop(),d=m[m.length-1],e=e.parent.parent):"from"===e.nodeType?e=e.parent:
"to"===e.nodeType?e=e.parent:"what"===e.nodeType?(m.pop(),d=m[m.length-1],e=e.parent.parent):"numerator"===e.nodeType?(d="denominator",e=e.parent):"denominator"===e.nodeType&&(r.pop(),c=r[r.length-1],m.pop(),d=m[m.length-1],e=e.parent.parent)}else"open"===h[q].type&&"{"===h[q].value&&null===d?e.addChild(new a.TextNode("{","text",c.clone(),null)):"close"===h[q].type&&"}"===h[q].value&&null===d&&e.addChild(new a.TextNode("}","text",c.clone(),null));var v,y,A=null,C=[];n.children.forEach(function(a){for(var b=
0,c=a.children.length;b<c-1;b++)v=a.children[b],y=a.children[b+1],"text"===v.nodeType&&"text"===y.nodeType?(null===A&&(A=v,l=v.clone(),A.changeNodeType("word"),A.value="___"+l.value,A.addChild(l)),l=y.clone(),A.addChild(l),C.push(y),A.value+=l.value):A=null});C.forEach(function(a){a.parent.removeChild(a)});n.adjustFontSize();return n.normalize()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k=[a.sansserif_font,a.serif_font,a.monospace_font];a.TextStyle=function(a){this.size=20;this.family="Arimo";this.overline=this.underline=this.bold=this.italic=!1;this.color=null;this.align="left";this.border=null;a=a||{};this.set(a)};a.TextStyle.prototype.clone=function(){var f={},h;for(h in this)this.hasOwnProperty(h)&&(f[h]=this[h]);return new a.TextStyle(f)};a.TextStyle.prototype.set=function(a){for(var f in a)a.hasOwnProperty(f)&&(this[f]=a[f])};
a.TextStyle.prototype.equals=function(a){var f=!0,e;for(e in this)this.hasOwnProperty(e)&&(f=f&&this[e]===a[e]);return f};a.TextStyle.prototype.toString=function(){/arial|sansserif/i.test(this.family)?h=k[0]:/times|serif/i.test(this.family)?h=k[1]:/courier|monospaced/i.test(this.family)&&(h=k[2]);return((this.bold?"bold":"")+" "+(this.italic?"italic":"")+" "+this.size+"px "+h).trim()};return a}(descartesJS||{});
descartesJS=function(a){function h(a,b){for(var c=0,g=0;g<b;g++)c+=a[g];return c}function k(a){var b={ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,marginX:0,marginY:0,paddingX:0,paddingY:0};if(""==a.trim())return b;var c=parseInt(a.match(/(\d+\.*)+px/)[0]);a=a.match("sansserif")?"sansserif":a.match("serif")?"serif":"monospace";b.ascent=Math.ceil((r[a].ascent+25)*c/r[a].unitsPerEm);b.descent=Math.ceil(Math.abs((r[a].descent-25)*c/r[a].unitsPerEm));b.h=b.ascent+b.descent;return b}if(a.loadLib)return a;
a.auxCtx=document.createElement("canvas").getContext("2d");var f="#000000",n=2,e=!1,m=new Path2D("m 759,1 c -8,0 -15,4 -20,14 L 325,878 153,500 c -5,-11 -11,-14 -17,-9 L 2,596 c -5,4 17,30 22,26 l 65,-47 193,422 c 3,6 27,6 32,-4 L 773,40 V 1 Z");m.svgData="m 759,1 c -8,0 -15,4 -20,14 L 325,878 153,500 c -5,-11 -11,-14 -17,-9 L 2,596 c -5,4 17,30 22,26 l 65,-47 193,422 c 3,6 27,6 32,-4 L 773,40 V 1 Z";var d=new Path2D("M 780,707 H 750 C 728,805 695,872 585,872 H 180 L 509,447 225,65 h 313 c 130,0 167,49 188,181 h 30 V 0 H 25 L 384,500 0,1000 h 729 z");
d.svgData="M 780,707 H 750 C 728,805 695,872 585,872 H 180 L 509,447 225,65 h 313 c 130,0 167,49 188,181 h 30 V 0 H 25 L 384,500 0,1000 h 729 z";var c=new Path2D("m 150,828 c -21,88 -42,144 -83,144 -6,0 -9,-2 -9,-6 0,-9 15,-8 15,-34 0,-14 -13,-22 -27,-22 -24,0 -45,22 -45,51 0,20 21,39 56,39 97,0 141,-105 159,-176 L 375,181 c 23,-91 45,-154 89,-153 6,0 9,2 9,6 0,7 -15,13 -15,35 0,14 13,20 27,20 24,0 45,-22 45,-51 C 530,18 508,0 473,0 368,0 326,120 309,190 Z");c.svgData="m 150,828 c -21,88 -42,144 -83,144 -6,0 -9,-2 -9,-6 0,-9 15,-8 15,-34 0,-14 -13,-22 -27,-22 -24,0 -45,22 -45,51 0,20 21,39 56,39 97,0 141,-105 159,-176 L 375,181 c 23,-91 45,-154 89,-153 6,0 9,2 9,6 0,7 -15,13 -15,35 0,14 13,20 27,20 24,0 45,-22 45,-51 C 530,18 508,0 473,0 368,0 326,120 309,190 Z";
a.TextNode=function(a,b,c,d){this.type="rtfNode";this.evaluator=d;this.parent=null;this.children=[];this.metrics={ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,marginX:0,marginY:0,paddingX:0,paddingY:0};this.value=a;this.style=c;this.changeNodeType(b);this.drawBorder=function(){}};a.TextNode.prototype.changeNodeType=function(a){this.nodeType=a;this.draw=null;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":case "mathSymbol":this.draw=this.drawText;break;case "space":this.draw=this.drawSpace;break;case "word":this.draw=this.drawWord;break;case "hyperlink":this.draw=this.drawHyperlink;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.TextNode.prototype.clone=function(){for(var c=new a.TextNode(this.value,this.nodeType,this.style.clone()),b=0,d=this.children.length;b<d;b++)c.addChild(this.children[b].clone());return c};a.TextNode.prototype.toStr=function(){for(var a=this.value,b=0,c=this.children.length;b<c;b++)a+=" "+this.children[b].toStr();return a};a.TextNode.prototype.stringify=function(){var a="{"+('"NT":"'+this.nodeType+'",');a+=
'"V":"'+(this.value||"")+'",';a+='"C":[';for(var b=0,c=this.children.length;b<c;b++)a+=this.children[b].stringify()+(b==c-1?"":",");a=a+"],"+('"S":'+JSON.stringify(this.style));return a+"}"};a.TextNode.prototype.addChild=function(a,b){b&&null!==a.parent&&a.parent.removeChild(a);a.parent=this;this.children.push(a)};a.TextNode.prototype.removeChild=function(a){var b=this.children.indexOf(a);-1!==b&&(a.parent=null,this.children.splice(b,1))};a.TextNode.prototype.getFirstTextNode=function(){for(var a=
this;0<a.children.length;)a=a.children[0];return a};a.TextNode.prototype.getLastTextNode=function(){for(var a=this;0<a.children.length;)a=a.children[a.children.length-1];return a};a.TextNode.prototype.nextSibling=function(){if(this.parent)for(var a=null,b=0,c=this.parent.children.length;b<c;b++){if(a)return this.parent.children[b];this.parent.children[b]===this&&(a=!0)}return null};a.TextNode.prototype.prevSibling=function(){if(this.parent)for(var a=0,b=this.parent.children.length-1;a<b;a++)if(this.parent.children[a+
1]===this)return this.parent.children[a];return null};a.TextNode.prototype.querySelectorAll=function(a){for(var b=[],c=0,d=this.children.length;c<d;c++)b=b.concat(this.children[c].querySelectorAll(a));this.nodeType===a&&b.push(this);return b};a.TextNode.prototype.insertBefore=function(a,b){a=this.children.indexOf(a);-1!==a&&(b.parent=this,this.children.splice(a,0,b))};a.TextNode.prototype.insertAfter=function(a,b){a=this.children.indexOf(a);-1!==a&&(b.parent=this,this.children.splice(a+1,0,b))};a.TextNode.prototype.normalize=
function(){for(var c=this.querySelectorAll("textLineBlock").concat(this.querySelectorAll("formula")).concat(this.querySelectorAll("numerator")).concat(this.querySelectorAll("denominator")).concat(this.querySelectorAll("superIndex")).concat(this.querySelectorAll("subIndex")).concat(this.querySelectorAll("index")).concat(this.querySelectorAll("subIndex")).concat(this.querySelectorAll("radicand")).concat(this.querySelectorAll("from")).concat(this.querySelectorAll("to")).concat(this.querySelectorAll("what")).concat(this.querySelectorAll("element")),
b=0,d=c.length;b<d;b++)0===c[b].children.length&&c[b].addChild(new a.TextNode("","text",c[b].style));c=this.querySelectorAll("formula").concat(this.querySelectorAll("fraction")).concat(this.querySelectorAll("superIndex")).concat(this.querySelectorAll("subIndex")).concat(this.querySelectorAll("radical")).concat(this.querySelectorAll("sum")).concat(this.querySelectorAll("integral")).concat(this.querySelectorAll("limit")).concat(this.querySelectorAll("matrix")).concat(this.querySelectorAll("defparts")).concat(this.querySelectorAll("dynamicText")).concat(this.querySelectorAll("componentNumCtrl")).concat(this.querySelectorAll("componentSpace"));
b=0;for(d=c.length;b<d;b++)(null===c[b].prevSibling()||null!==c[b].prevSibling()&&"text"!==c[b].prevSibling().nodeType)&&c[b].parent.insertBefore(c[b],new a.TextNode("","text",c[b].parent.style)),(null===c[b].nextSibling()||null!==c[b].nextSibling()&&"text"!==c[b].nextSibling().nodeType)&&c[b].parent.insertAfter(c[b],new a.TextNode("","text",c[b].parent.style));return this};a.TextNode.prototype.removeEmptyText=function(){for(var a=this.querySelectorAll("text"),b=0,c=a.length;b<c;b++)""===a[b].value&&
a[b].parent&&a[b].parent.removeChild(a[b])};a.TextNode.prototype.adjustFontSize=function(a){var b=this.style.size;"formula"===this.nodeType&&(a=!0);for(var c=0,d=this.children.length;c<d;c++)"text"===this.children[c].nodeType&&a?(this.children[c].style.size=b,this.children[c].styleString=this.children[c].style.toString()):"index"===this.children[c].nodeType?(this.children[c].style.size=Math.max(parseInt(b-.5*b),8),this.children[c].styleString=this.children[c].style.toString(),this.children[c].adjustFontSize(!0)):
"to"===this.children[c].nodeType||"from"===this.children[c].nodeType?(this.children[c].style.size=Math.max(parseInt(b-.2*b),8),this.children[c].styleString=this.children[c].style.toString(),this.children[c].adjustFontSize(!0)):"numerator"===this.children[c].nodeType||"denominator"===this.children[c].nodeType?(this.children[c].style.size=Math.max(parseInt(b-.1*b),8),this.children[c].styleString=this.children[c].style.toString(),this.children[c].adjustFontSize(!0)):"subIndex"===this.children[c].nodeType||
"superIndex"===this.children[c].nodeType?(this.children[c].style.size=Math.max(parseInt(b-.33*b),8),this.children[c].styleString=this.children[c].style.toString(),this.children[c].adjustFontSize(!0)):(a&&(this.children[c].style.size=b,this.children[c].styleString=this.children[c].style.toString()),this.children[c].adjustFontSize(a))};a.TextNode.prototype.propagateStyle=function(a,b){this.style[a]=b;this.styleString=this.style.toString();for(var c=0,d=this.children.length;c<d;c++)this.children[c].propagateStyle(a,
b)};a.TextNode.prototype.update=function(a,b,c,d,h,k,m,r){n=c;e=d;f=m;this.metrics.w=this.metrics.h=0;m=b;if(20<=r)for(c=0;c<this.children.length;c++)this.children[c].breakLines(r);c=0;for(h=this.children.length;c<h;c++){var g=this.children[c];g.updateLine();g.metrics.offsetX=a;g.metrics.y=b;b+=parseInt(g.metrics.ascent+.5);g.metrics.offsetY=b;d=parseInt(g.metrics.descent+.5)+parseInt(1.5+.05*g.style.size);b+=d;this.metrics.h+=g.metrics.h;this.metrics.w=Math.max(this.metrics.w,g.metrics.w)}b=m;k=
k||"";k.match("right")?a-=this.metrics.w:k.match("_center")&&(a-=this.metrics.w/2);k.match("bottom")?b-=this.metrics.h:k.match("center_")&&(b-=this.metrics.h/2);k=this.children;c=0;for(h=k.length;c<h;c++)"left"===k[c].style.align?k[c].metrics.offsetX=a:"right"===k[c].style.align?k[c].metrics.offsetX=a+this.metrics.w-k[c].metrics.w:"center"===k[c].style.align?k[c].metrics.offsetX=a+(this.metrics.w-k[c].metrics.w)/2:"justify"===k[c].style.align&&20<=r&&(lineValue=c<h-1?k[c+1].value:null,k[c].metrics.offsetX=
a,"wrap"===lineValue&&k[c].justifyAux(r)),k[c].metrics.y=b,b+=parseInt(k[c].metrics.ascent+.5),k[c].metrics.offsetY=b,d=parseInt(k[c].metrics.descent+.5)+parseInt(1.5+.05*k[c].style.size),b+=d};a.TextNode.prototype.breakLines=function(c){for(var b,d=0,g=!1,e=[],f=0,h=this.children.length;f<h;f++)b=this.children[f],g?e.push(b):("text"===b.nodeType||"space"===b.nodeType?(a.auxCtx.font=b.style.toString(),b.metrics.w=a.auxCtx.measureText(b.value).width):"word"===b.nodeType?b.updateLine():"formula"===
b.nodeType&&b.updateFormula(),d+=b.metrics.w,d>c&&"space"!==b.nodeType&&0<f&&(g=!0,e.push(b)));if(0<e.length)for(c=new a.TextNode("wrap","textLineBlock",this.style.clone(),null),this.parent.insertAfter(this,c),f=0,h=e.length;f<h;f++)e[f].parent&&e[f].parent.removeChild(e[f]),c.addChild(e[f])};a.TextNode.prototype.updateLine=function(c){var b=this;if("textLineBlock"===this.nodeType||"word"===this.nodeType){this.metrics.w=0;this.metrics.ascent=0;for(var d=this.metrics.descent=0,g=this.children,e,f=
0,h=g.length;f<h;f++){e=g[f];if("text"===e.nodeType){a.auxCtx.font=e.style.toString();var m=""!==e.value?e.value:"\u200a";e.metrics=k(a.auxCtx.font);e.metrics.w=a.auxCtx.measureText(m).width;e.metrics.offsetX=d;Object.defineProperties(e.metrics,{x:{get:function(){return b.metrics.offsetX+this.offsetX}},y:{get:function(){return b.metrics.offsetY+this.offsetY}}})}"space"===e.nodeType?(a.auxCtx.font=e.style.toString(),e.metrics=k(a.auxCtx.font),e.metrics.w=f===h-1?0:c?c:a.auxCtx.measureText(" ").width,
e.metrics.offsetX=d,Object.defineProperties(e.metrics,{x:{get:function(){return b.metrics.offsetX+this.offsetX}},y:{get:function(){return b.metrics.offsetY+this.offsetY}}})):"word"===e.nodeType&&(e.updateLine(),e.metrics.offsetX_aux=d,Object.defineProperties(e.metrics,{offsetX:{get:function(){return b.metrics.offsetX+this.offsetX_aux}},offsetY:{get:function(){return b.metrics.offsetY}}}));"hyperlink"===e.nodeType&&(a.auxCtx.font=e.styleString,m=""!==e.value?e.value:"\u200a",e.metrics=k(a.auxCtx.font),
e.metrics.w=a.auxCtx.measureText(m).width,e.metrics.offsetX=d,Object.defineProperties(e.metrics,{x:{get:function(){return b.metrics.offsetX+this.offsetX}},y:{get:function(){return b.metrics.offsetY}}}),e.clickCacher||(e.clickCacher=document.createElement("div"),e.clickCacher.setAttribute("style","position:absolute;width:"+e.metrics.w+"px;height:"+e.metrics.h+"px;cursor:pointer;"),e.clickCacher.rtfNode=e,e.clickCacher.action=new a.OpenURL(this.evaluator.parent,e.URL),e.clickCacher.addEventListener("click",
function(a){this.rtfNode.click=!0;this.action.execute();this.rtfNode.draw(this.rtfNode.ctx)})));"componentNumCtrl"===e.nodeType&&(e.componentNumCtrl=this.evaluator.parent.getControlByCId(e.value),a.auxCtx.font=e.styleString,e.metrics=k(a.auxCtx.font),e.metrics.w=e.componentNumCtrl.w,e.metrics.h=e.componentNumCtrl.h,e.metrics.offsetX=d,Object.defineProperties(e.metrics,{x:{get:function(){return b.metrics.offsetX+this.offsetX}},y:{get:function(){return b.metrics.offsetY}}}));"componentSpace"===e.nodeType?
(e.componentSpace=this.evaluator.parent.getSpaceByCId(e.value),a.auxCtx.font=e.styleString,e.metrics=k(a.auxCtx.font),e.metrics.w=e.componentSpace.w,e.metrics.h=e.componentSpace.h,e.metrics.offsetX=d,Object.defineProperties(e.metrics,{x:{get:function(){return b.metrics.offsetX+this.offsetX}},y:{get:function(){return b.metrics.offsetY}}})):"formula"===e.nodeType&&(e.updateFormula(),e.metrics.offsetX_aux=d,Object.defineProperties(e.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return b.metrics.offsetX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return b.metrics.offsetY}}}),e.metrics.w+=2*e.metrics.paddingX,e.metrics.ascent+=e.metrics.paddingY,e.metrics.descent+=e.metrics.paddingY,e.metrics.h+=2*e.metrics.paddingY,d+=2*e.metrics.marginX);this.metrics.w+=e.metrics.w+2*e.metrics.marginX;this.metrics.ascent=Math.max(this.metrics.ascent,e.metrics.ascent);this.metrics.descent=Math.max(this.metrics.descent,e.metrics.descent);d+=e.metrics.w}this.metrics.h=
this.metrics.ascent+this.metrics.descent}};a.TextNode.prototype.updateFormula=function(){var c=this;this.metrics={ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,marginX:0,marginY:0,paddingX:0,paddingY:0};for(var b=this.children,d,f=0,m={metrics:{ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,marginX:0,marginY:0,paddingX:0,paddingY:0}},r=0,x=b.length;r<x;r++){d=b[r];if("text"===d.nodeType){a.auxCtx.font=d.style.toString();var p=""!==d.value?d.value:"\u200a";d.metrics=k(a.auxCtx.font);
d.metrics.w=a.auxCtx.measureText(p).width;d.metrics.offsetX=f;Object.defineProperties(d.metrics,{x:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX}},y:{get:function(){return c.metrics.offsetY}}});f+=c.metrics.marginX}else if("dynamicText"===d.nodeType){p=void 0===d.decimals?n:d.evaluator.eval(d.decimals);var v=void 0===d.fixed?e:d.fixed,y=d.evaluator.eval(d.value);parseFloat(y).toString()===y.toString()&&(y=v?parseFloat(y).toFixed(p):a.removeNeedlessDecimals(parseFloat(y).toFixed(p)),
y=(""+y).replace(".",d.decimal_symbol));d.evalValue=y;a.auxCtx.font=d.style.toString();d.metrics=k(a.auxCtx.font);d.metrics.marginX=parseInt(1.5+.075*this.style.size);d.metrics.paddingX=parseInt(1.5+.075*this.style.size);d.metrics.w=a.auxCtx.measureText(y).width+2*d.metrics.paddingX;d.metrics.offsetX_aux=f;Object.defineProperties(d.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX_aux+
this.marginX}},offsetY:{get:function(){return c.metrics.offsetY}}});f+=2*d.metrics.marginX}if("superIndex"===d.nodeType)p=d,p.updateFormula(),p.metrics.marginX=0*parseInt(1.5+.075*this.style.size),p.metrics.paddingX=0*parseInt(1.5+.075*this.style.size),p.metrics.paddingY=parseInt(1.5+.05*this.style.size),p.metrics.offsetX_aux=f,p.metrics.prevChild=m,Object.defineProperties(p.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+
c.metrics.paddingX+this.offsetX_aux+this.marginX}},offsetY:{get:function(){return c.metrics.offsetY-this.descent+this.prevChild.metrics.descent-parseInt(2*this.prevChild.metrics.h/7)}}}),p.metrics.w+=2*p.metrics.paddingX,p.metrics.ascent+=p.metrics.paddingY,p.metrics.descent+=p.metrics.paddingY,p.metrics.h+=2*p.metrics.paddingY,this.metrics.ascent=p.metrics.descent-p.metrics.prevChild.metrics.descent+parseInt(2*p.metrics.prevChild.metrics.h/7)+p.metrics.ascent,f+=2*p.metrics.marginX;else if("subIndex"===
d.nodeType){var A=d;A.updateFormula();A.metrics.marginX=parseInt(1.5+.09375*this.style.size);A.metrics.paddingX=0*parseInt(1.5+.01875*this.style.size);A.metrics.paddingY=parseInt(1.5+.05*this.style.size);A.metrics.offsetX_aux=f;A.metrics.prevChild=m;Object.defineProperties(A.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX_aux+0*this.marginX}},offsetY:{get:function(){return c.metrics.offsetY+
this.ascent+A.metrics.prevChild.metrics.descent-parseInt(4*A.metrics.prevChild.metrics.h/7)}}});A.metrics.w+=A.metrics.paddingX;A.metrics.ascent+=A.metrics.paddingY;A.metrics.descent+=A.metrics.paddingY;A.metrics.h+=2*A.metrics.paddingY;this.metrics.descent=A.metrics.ascent+A.metrics.prevChild.metrics.descent-parseInt(4*A.metrics.prevChild.metrics.h/7)+A.metrics.descent;f+=A.metrics.marginX}else if("fraction"===d.nodeType){v=d;v.updateFormula();p=v.children;y=p[0];p=p[1];v.metrics.marginX=parseInt(1.5+
.075*this.style.size);v.metrics.paddingX=0*parseInt(1.5+.075*this.style.size);v.metrics.paddingY=0*parseInt(1.5+.05*this.style.size);var C=Math.max(y.metrics.w,p.metrics.w)+2*v.metrics.paddingX;v.metrics.prevChild=m;v.metrics.offsetX_aux=f;var I=parseInt(-m.metrics.descent+4*m.metrics.h/9);Object.defineProperties(v.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY+I}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},
offsetY:{get:function(){return c.metrics.offsetY-I}}});Object.defineProperties(y.metrics,{parent:{value:v},maxWidth:{value:C},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+parseInt((this.maxWidth-this.w)/2)}},offsetY:{get:function(){return this.parent.metrics.offsetY-this.descent-this.parent.metrics.paddingY}}});Object.defineProperties(p.metrics,{parent:{value:v},maxWidth:{value:C},x:{get:function(){return this.offsetX}},
y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+parseInt((this.maxWidth-this.w)/2)}},offsetY:{get:function(){return this.parent.metrics.offsetY+this.ascent+this.parent.metrics.paddingY}}});v.metrics.w=C;v.metrics.ascent=y.metrics.h+I+2*v.metrics.paddingY;v.metrics.descent=p.metrics.h-I+2*v.metrics.paddingY;v.metrics.h=y.metrics.h+p.metrics.h+4*v.metrics.paddingY;f+=2*v.metrics.marginX}else if("radical"===d.nodeType){m=d;m.updateFormula();p=m.children;
v=p[0];var G=p[1];m.metrics.marginX=parseInt(1.5+.075*this.style.size);m.metrics.paddingX=parseInt(1.5+.075*this.style.size);m.metrics.paddingY=parseInt(1.5+.05*this.style.size);m.metrics.offsetX_aux=f;Object.defineProperties(m.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});p=m.style.size;m.radicalSign={w:p,
scaleX:p/722,scaleY:G.metrics.h/1E3};y=parseInt(v.metrics.w-2*m.radicalSign.w/3);Object.defineProperties(m.radicalSign,{parent:{value:m},displaceIndex:{value:y},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+Math.max(this.displaceIndex,0)}},y:{get:function(){return c.metrics.offsetY-G.metrics.ascent}}});Object.defineProperties(v.metrics,{parent:{value:m},displaceIndex:{value:y},fontSize:{value:p},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+Math.max(this.displaceIndex,0)-this.displaceIndex}},offsetY:{get:function(){return c.metrics.offsetY-this.descent-2*this.fontSize/5}}});Object.defineProperties(G.metrics,{parent:{value:m},displaceIndex:{value:y},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+this.parent.radicalSign.w+Math.max(this.displaceIndex,
0)}},offsetY:{get:function(){return c.metrics.offsetY}}});y=v.metrics.w<2*m.radicalSign.w/3?m.radicalSign.w:parseInt(v.metrics.w+m.radicalSign.w/3);m.metrics.w=y+2*m.metrics.paddingX+G.metrics.w;m.metrics.ascent=Math.max(G.metrics.ascent,v.metrics.h+2*p/5)+m.metrics.paddingY;m.metrics.descent=G.metrics.descent+m.metrics.paddingY;m.metrics.h=m.metrics.ascent+m.metrics.descent;f+=2*m.metrics.marginX}else if("sum"===d.nodeType){v=d;v.updateFormula();p=v.children;y=p[0];C=p[1];var K=p[2];v.metrics.marginX=
parseInt(1.5+.075*this.style.size);v.metrics.paddingX=parseInt(1.5+.075*this.style.size);v.metrics.paddingY=parseInt(1.5+.05*this.style.size);v.metrics.offsetX_aux=f;Object.defineProperties(v.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});a.auxCtx.font=d.style.toString();var E=k(a.auxCtx.font);m=parseInt(1.2*
E.h);p=parseInt(.5+780*m/1E3);v.sigmaSign={w:p,h:m,scale:m/1E3};var z=Math.max(C.metrics.w,y.metrics.w,v.sigmaSign.w);v.sigmaSign.parent=v;Object.defineProperties(v.sigmaSign,{sumWidth:{value:z},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.sumWidth-this.w)/2)}},y:{get:function(){return c.metrics.offsetY+E.descent-(this.h+E.h)/2}}});p=E.descent-C.metrics.descent-(m+E.h)/2-v.metrics.paddingY;Object.defineProperties(C.metrics,{parent:{value:v},sumWidth:{value:z},
newBaselineTo:{value:p},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.sumWidth-this.w)/2)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineTo}}});m=y.metrics.ascent+E.descent+(m-E.h)/2+v.metrics.paddingY;Object.defineProperties(y.metrics,{parent:{value:v},sumWidth:{value:z},newBaselineFrom:{value:m},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.sumWidth-this.w)/2)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineFrom}}});Object.defineProperties(K.metrics,{parent:{value:v},sumWidth:{value:z},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+2*this.parent.metrics.paddingX+this.sumWidth}},offsetY:{get:function(){return c.metrics.offsetY}}});
v.metrics.w=z+K.metrics.w+3*v.metrics.paddingX;v.metrics.ascent=Math.max(K.metrics.ascent,-p+C.metrics.ascent)+v.metrics.paddingY;v.metrics.descent=Math.max(K.metrics.descent,m+y.metrics.descent)+v.metrics.paddingY;v.metrics.h=v.metrics.ascent+v.metrics.descent;f+=2*v.metrics.marginX}else if("integral"===d.nodeType){v=d;v.updateFormula();p=v.children;y=p[0];C=p[1];K=p[2];v.metrics.marginX=parseInt(1.5+.075*this.style.size);v.metrics.paddingX=parseInt(1.5+.075*this.style.size);v.metrics.paddingY=parseInt(1.5+
.05*this.style.size);v.metrics.offsetX_aux=f;Object.defineProperties(v.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});a.auxCtx.font=d.style.toString();E=k(a.auxCtx.font);z=parseInt(1.2*E.h);var F=parseInt(10.5+529*z/1E3);v.sign={w:F,h:z,scale:z/1E3};v.sign.parent=v;Object.defineProperties(v.sign,{x:{get:function(){return this.parent.metrics.offsetX+
this.parent.metrics.paddingX}},y:{get:function(){return c.metrics.offsetY+E.descent-(this.h+E.h)/2}}});p=E.descent-(z+E.h)/2-C.metrics.descent+z/3;Object.defineProperties(C.metrics,{parent:{value:v},integralWidth:{value:F},newBaselineTo:{value:p},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt(4*this.integralWidth/5)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineTo}}});
m=E.descent+y.metrics.ascent/2;Object.defineProperties(y.metrics,{parent:{value:v},integralWidth:{value:F},newBaselineFrom:{value:m},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt(2*this.integralWidth/5)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineFrom}}});F=Math.max(parseInt(4*F/5)+C.metrics.w,parseInt(2*F/5+y.metrics.w))+v.metrics.paddingX;Object.defineProperties(K.metrics,
{parent:{value:v},whatDisplace:{value:F},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+this.whatDisplace}},offsetY:{get:function(){return c.metrics.offsetY}}});v.metrics.w=F+K.metrics.w+2*v.metrics.paddingX;v.metrics.ascent=Math.max(K.metrics.ascent,-p+C.metrics.ascent)+v.metrics.paddingY;v.metrics.descent=Math.max(K.metrics.descent,m+y.metrics.descent,z-v.metrics.ascent)+v.metrics.paddingY;
v.metrics.h=Math.max(v.metrics.ascent+v.metrics.descent,z);f+=2*v.metrics.marginX}else if("limit"===d.nodeType){m=d;m.updateFormula();p=m.children;var L=p[0];v=p[1];p=p[2];m.metrics.marginX=parseInt(1.5+.075*this.style.size);m.metrics.paddingX=parseInt(1.5+.075*this.style.size);m.metrics.paddingY=parseInt(1.5+.05*this.style.size);m.metrics.offsetX_aux=f;Object.defineProperties(m.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+
c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});a.auxCtx.font=d.style.toString();E=k(a.auxCtx.font);C=parseInt(.5+a.auxCtx.measureText("l\u00edm").width);y=parseInt(.5+a.auxCtx.measureText("\u2192").width);limitWidth=Math.max(C,L.metrics.w+y+v.metrics.w);m.limitText={parent:m};Object.defineProperties(m.limitText,{limitWidth:{value:limitWidth},limitTextWidth:{value:C},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+
(this.limitWidth-this.limitTextWidth)/2}}});C=E.descent+Math.max(L.metrics.ascent,v.metrics.ascent,2*E.ascent/3)+m.metrics.paddingY;m.limitArrow={parent:m};Object.defineProperties(m.limitArrow,{newBaseline:{value:C},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+L.metrics.w}},y:{get:function(){return c.metrics.offsetY+this.newBaseline}}});Object.defineProperties(L.metrics,{parent:{value:m},newBaseline:{value:C},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaseline}}});Object.defineProperties(v.metrics,{parent:{value:m},arrowWidth:{value:y},newBaseline:{value:C},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+L.metrics.w+this.arrowWidth}},offsetY:{get:function(){return c.metrics.offsetY+
this.newBaseline}}});Object.defineProperties(p.metrics,{parent:{value:m},limitWidth:{value:limitWidth},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+2*this.parent.metrics.paddingX+this.limitWidth}},offsetY:{get:function(){return c.metrics.offsetY}}});m.metrics.w=limitWidth+p.metrics.w+3*m.metrics.paddingX;m.metrics.ascent=Math.max(p.metrics.ascent,E.ascent)+m.metrics.paddingY;m.metrics.descent=C+Math.max(L.metrics.descent,
v.metrics.descent)+m.metrics.paddingY;m.metrics.h=m.metrics.ascent+m.metrics.descent;f+=2*m.metrics.marginX}else if("matrix"===d.nodeType){y=d;y.updateFormula();p=y.children;C=y.rows;K=y.columns;y.metrics.marginX=parseInt(1.5+.075*this.style.size);y.metrics.paddingX=parseInt(1.5+.075*this.style.size);y.metrics.paddingY=parseInt(1.5+.05*this.style.size);y.metrics.offsetX_aux=f;Object.defineProperties(y.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+
c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});a.auxCtx.font=d.style.toString();E=k(a.auxCtx.font);z=[];F=[];m=0;for(var N=C*K;m<N;m++){var M=parseInt(m/K);var B=m%K;z[M]=Math.max(z[M]||0,p[m].metrics.h);F[B]=Math.max(F[B]||0,p[m].metrics.w)}var D=(1+K)*y.metrics.paddingX;for(m=0;m<K;m++)D+=F[m];var J=(1+C)*y.metrics.paddingY;for(m=0;m<C;m++)J+=z[m];v=E.descent-E.h/2;m=0;for(N=C*K;m<N;m++)M=parseInt(m/K),B=m%K,p[m].metrics.offsetX_aux=h(F,B)+
(F[B]-p[m].metrics.w)/2+B*y.metrics.paddingX,p[m].metrics.offsetY_aux=h(z,M)+(z[M]-p[m].metrics.h)/2+(1+M)*y.metrics.paddingY,Object.defineProperties(p[m].metrics,{parent:{value:y},matrixH:{value:J},dispY:{value:v},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY-this.matrixH/2+this.ascent+this.offsetY_aux+this.dispY}}});
y.metrics.w=D;y.metrics.ascent=J/2-v;y.metrics.descent=J/2+v;y.metrics.h=y.metrics.ascent+y.metrics.descent;f+=2*y.metrics.marginX}else if("defparts"===d.nodeType){y=d;y.updateFormula();p=d.children;C=d.parts;y.metrics.marginX=parseInt(1.5+.075*this.style.size);y.metrics.paddingX=parseInt(1.5+.075*this.style.size);y.metrics.paddingY=parseInt(1.5+.05*this.style.size);y.metrics.offsetX_aux=f;Object.defineProperties(y.metrics,{parent:{value:c},x:{get:function(){return this.offsetX-2*this.marginX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+3*this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});a.auxCtx.font=d.style.toString();E=k(a.auxCtx.font);K=0;z=y.metrics.paddingY;v=E.descent-E.h/2;for(m=0;m<C;m++)p[m].metrics.offsetY_aux=z,K=Math.max(K,p[m].metrics.w),z+=p[m].metrics.h+y.metrics.paddingY,Object.defineProperties(p[m].metrics,{parent:{value:y},dispY:{value:v},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX}},offsetY:{get:function(){return c.metrics.offsetY-this.parent.metrics.defpartsH/2+this.ascent+this.offsetY_aux+this.dispY}}});y.metrics.defpartsH=z;y.metrics.w=K+4*y.metrics.paddingX;y.metrics.ascent=z/2-v;y.metrics.descent=z/2+v;y.metrics.h=y.metrics.ascent+y.metrics.descent;f+=2*y.metrics.marginX}else if("numerator"===d.nodeType||"denominator"===d.nodeType||"index"===d.nodeType||"radicand"===d.nodeType||"from"===
d.nodeType||"to"===d.nodeType||"what"===d.nodeType||"element"===d.nodeType)d.updateFormula(),d.metrics.paddingX=parseInt(1.5+.075*this.style.size),d.metrics.paddingY=parseInt(1.5+.05*this.style.size),d.metrics.w+=2*d.metrics.paddingX,d.metrics.ascent+=d.metrics.paddingY,d.metrics.descent+=d.metrics.paddingY,d.metrics.h=d.metrics.ascent+d.metrics.descent;m=d;this.metrics.ascent=Math.max(this.metrics.ascent,d.metrics.ascent);this.metrics.descent=Math.max(this.metrics.descent,d.metrics.descent);this.metrics.w+=
d.metrics.w+2*d.metrics.marginX;this.metrics.h=this.metrics.ascent+this.metrics.descent;f+=d.metrics.w}};a.TextNode.prototype.justifyAux=function(a){for(var b=0,c=0,d=0,e=this.children.length;d<e-1;d++)"space"===this.children[d].nodeType?b++:c+=this.children[d].metrics.w;this.updateLine((a-c)/b)};a.TextNode.prototype.drawTextBlock=function(a){a.fillStyle=f;for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a)};a.TextNode.prototype.drawTextLineBlock=function(a){for(var b=0,c=this.children.length;b<
c;b++)this.children[b].draw(a)};a.TextNode.prototype.drawText=function(a){if(""!==this.value){var b=this.metrics.x,c=this.metrics.y;a.fillStyle=null!==this.style.color?this.style.color.getColor?this.style.color.getColor():this.style.color:f;a.font=this.style.toString();a.beginPath();this.style.overline&&(a.rect(b,c-this.metrics.ascent+parseInt(1+this.style.size/25),this.metrics.w,parseInt(1+this.style.size/25)),a.fill());this.style.underline&&(a.rect(b,c+parseInt(1+this.style.size/10),this.metrics.w,
parseInt(1+this.style.size/25)),a.fill());if(this.style.border){var d=a.strokeStyle;a.lineWidth=1+parseInt(this.style.size/13);a.lineJoin="round";a.miterLimit=2;a.strokeStyle=this.style.border.getColor();a.strokeText(this.value,b,c);a.strokeStyle=d}a.fillText(this.value,b,c)}};a.TextNode.prototype.drawWord=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a)};a.TextNode.prototype.drawSpace=function(a){};a.TextNode.prototype.drawDynamicText=function(a){var b=this.metrics.x+
this.metrics.paddingX,c=this.metrics.y;a.fillStyle=null!==this.style.color?this.style.color.getColor?this.style.color.getColor():this.style.color:f;a.font=this.style.toString();a.beginPath();this.style.overline&&(a.rect(b,c-this.metrics.ascent+parseInt(1+this.style.size/25),this.metrics.w,parseInt(1+this.style.size/25)),a.fill());this.style.underline&&(a.rect(b,c+parseInt(1+this.style.size/10),this.metrics.w,parseInt(1+this.style.size/25)),a.fill());a.fillText(this.evalValue,b,c);this.drawBorder(a,
"blue")};a.TextNode.prototype.drawHyperlink=function(a){var b=this.metrics.x,c=this.metrics.y;this.ctx=a;this.clickCacher.parentNode||(a.canvas.nextSibling.className?a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling.nextSibling):a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling));this.clickCacher.style.left=b+"px";this.clickCacher.style.top=c-this.metrics.ascent+"px";a.fillStyle="blue";this.click&&(a.fillStyle="white",a.fillRect(b,c-this.metrics.ascent,this.metrics.w,
this.metrics.h),a.fillStyle="red");a.font=this.style.toString();a.beginPath();a.rect(b,c+parseInt(1+this.style.size/10),this.metrics.w,parseInt(1+this.style.size/25));a.fill();a.fillText(this.value,b,c)};a.TextNode.prototype.drawFormula=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);this.drawBorder(a,"blue")};a.TextNode.prototype.drawFraction=function(a){a.lineWidth=5;a.fillStyle=null!==this.style.color?this.style.color.getColor?this.style.color.getColor():this.style.color:
f;a.beginPath();var b=parseInt(1+this.style.size/24);a.rect(this.metrics.x,this.metrics.offsetY-parseInt(b/2),this.metrics.w,b);a.fill();this.children[0].draw(a);this.children[1].draw(a);this.drawBorder(a,"blue")};a.TextNode.prototype.drawNumDen=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);this.drawBorder(a,"blue")};a.TextNode.prototype.drawSuperIndex=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);this.drawBorder(a,"blue")};a.TextNode.prototype.drawSubIndex=
function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);this.drawBorder(a,"blue")};a.TextNode.prototype.drawRadical=function(c){c.save();c.translate(this.radicalSign.x,this.radicalSign.y);c.scale(this.radicalSign.scaleX,this.radicalSign.scaleY);a.isMsEdge?this.drawRadicalSign(c):c.fill(m);c.restore();c.beginPath();c.fillRect(this.children[1].metrics.x+2.5,this.radicalSign.y-.5,this.children[1].metrics.w-1.5,parseInt(1+this.style.size/18));for(var b=0,d=this.children.length;b<
d;b++)this.children[b].draw(c);this.drawBorder(c,"blue")};a.TextNode.prototype.drawSum=function(c){c.save();c.translate(this.sigmaSign.x,this.sigmaSign.y);c.scale(this.sigmaSign.scale,this.sigmaSign.scale);a.isMsEdge?this.drawSigmaSign(c):c.fill(d);c.restore();for(var b=0,e=this.children.length;b<e;b++)this.children[b].draw(c);this.drawBorder(c,"blue")};a.TextNode.prototype.drawIntegral=function(d){d.save();d.translate(this.sign.x,this.sign.y);d.scale(this.sign.scale,this.sign.scale);a.isMsEdge?this.drawIntegralSign(d):
d.fill(c);d.restore();for(var b=0,e=this.children.length;b<e;b++)this.children[b].draw(d);this.drawBorder(d,"blue")};a.TextNode.prototype.drawLimit=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);a.fillStyle=null!==this.style.color?this.style.color.getColor?this.style.color.getColor():this.style.color:f;a.font=this.style.toString();a.fillText("l\u00edm",this.limitText.x,this.metrics.y);a.fillText("\u2192",this.limitArrow.x,this.limitArrow.y);this.drawBorder(a,"blue")};
a.TextNode.prototype.drawMatrix=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);b=parseInt(1.5+this.style.size/25);c=b/2;a.lineWidth=b;a.strokeStyle=null!==this.style.color?this.style.color.getColor?this.style.color.getColor():this.style.color:f;a.beginPath();a.moveTo(this.metrics.x+c+1.5*this.metrics.marginX,this.metrics.y+c-this.metrics.ascent);a.lineTo(this.metrics.x+c,this.metrics.y+c-this.metrics.ascent);a.lineTo(this.metrics.x+c,this.metrics.y-c-this.metrics.ascent+
this.metrics.h);a.lineTo(this.metrics.x+c+1.5*this.metrics.marginX,this.metrics.y-c-this.metrics.ascent+this.metrics.h);a.moveTo(this.metrics.x+this.metrics.w-c-1.5*this.metrics.marginX,this.metrics.y+c-this.metrics.ascent);a.lineTo(this.metrics.x+this.metrics.w-c,this.metrics.y+c-this.metrics.ascent);a.lineTo(this.metrics.x+this.metrics.w-c,this.metrics.y+c-this.metrics.ascent+this.metrics.h);a.lineTo(this.metrics.x+this.metrics.w-c-1.5*this.metrics.marginX,this.metrics.y+c-this.metrics.ascent+this.metrics.h);
a.stroke();this.drawBorder(a,"blue")};a.TextNode.prototype.drawDefparts=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);c=parseInt(1.5+this.style.size/25);b=c/2;a.lineWidth=c;a.strokeStyle=null!==this.style.color?this.style.color.getColor?this.style.color.getColor():this.style.color:f;a.beginPath();c=3*this.metrics.marginX;var d=c/2;a.moveTo(this.metrics.x+b+c,this.metrics.y+b-this.metrics.ascent);a.bezierCurveTo(this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent,
this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent,this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent+2*this.metrics.marginX);a.lineTo(this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent+this.metrics.h/2-5*this.metrics.marginX);a.bezierCurveTo(this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent+this.metrics.h/2,this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent+this.metrics.h/2,this.metrics.x+b,this.metrics.y+b-this.metrics.ascent+this.metrics.h/2);a.bezierCurveTo(this.metrics.x+
b+d,this.metrics.y+b-this.metrics.ascent+this.metrics.h/2,this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent+this.metrics.h/2,this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent+this.metrics.h/2+5*this.metrics.marginX);a.lineTo(this.metrics.x+b+d,this.metrics.y+b-this.metrics.ascent+this.metrics.h-2*this.metrics.marginX);a.bezierCurveTo(this.metrics.x+b+d,this.metrics.y-b-this.metrics.ascent+this.metrics.h,this.metrics.x+b+d,this.metrics.y-b-this.metrics.ascent+this.metrics.h,this.metrics.x+
b+c,this.metrics.y-b-this.metrics.ascent+this.metrics.h);a.stroke();this.drawBorder(a,"blue")};a.TextNode.prototype.drawGenericBlock=function(a){for(var b=0,c=this.children.length;b<c;b++)this.children[b].draw(a);this.drawBorder(a,"blue")};a.TextNode.prototype.drawComponentNumCtrl=function(a){this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+this.metrics.x+","+(this.metrics.y-this.metrics.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")");this.componentNumCtrl&&this.componentNumCtrl.parent&&
this.componentNumCtrl.parent.readyApp&&this.componentNumCtrl.update(!0)};a.TextNode.prototype.drawComponentSpace=function(a){this.componentSpace.xExpr=this.evaluator.parser.parse(this.metrics.x.toString());this.componentSpace.yExpr=this.evaluator.parser.parse((this.metrics.y-this.metrics.ascent).toString());this.componentSpace&&this.componentSpace.parent&&this.componentSpace.parent.readyApp&&this.componentSpace.update(!0)};a.TextNode.prototype.drawRadicalSign=function(a){a.strokeStyle="rgba(0,0,0,0)";
a.lineCap="butt";a.lineJoin="miter";a.miterLimit=4;a.beginPath();a.moveTo(759,1);a.bezierCurveTo(751,1,744,5,739,15);a.lineTo(325,878);a.lineTo(153,500);a.bezierCurveTo(148,489,142,486,136,491);a.lineTo(2,596);a.bezierCurveTo(-3,600,19,626,24,622);a.lineTo(89,575);a.lineTo(282,997);a.bezierCurveTo(285,1003,309,1003,314,993);a.lineTo(773,40);a.lineTo(773,1);a.closePath();a.fill();a.stroke()};a.TextNode.prototype.drawSigmaSign=function(a){a.strokeStyle="rgba(0,0,0,0)";a.lineCap="butt";a.lineJoin="miter";
a.miterLimit=4;a.beginPath();a.moveTo(780,707);a.lineTo(750,707);a.bezierCurveTo(728,805,695,872,585,872);a.lineTo(180,872);a.lineTo(509,447);a.lineTo(225,65);a.lineTo(538,65);a.bezierCurveTo(668,65,705,114,726,246);a.lineTo(756,246);a.lineTo(756,0);a.lineTo(25,0);a.lineTo(384,500);a.lineTo(0,1E3);a.lineTo(729,1E3);a.closePath();a.fill();a.stroke()};a.TextNode.prototype.drawIntegralSign=function(a){a.strokeStyle="rgba(0,0,0,0)";a.lineCap="butt";a.lineJoin="miter";a.miterLimit=4;a.beginPath();a.moveTo(150,
828);a.bezierCurveTo(129,916,108,972,67,972);a.bezierCurveTo(61,972,58,970,58,966);a.bezierCurveTo(58,957,73,958,73,932);a.bezierCurveTo(73,918,60,910,46,910);a.bezierCurveTo(22,910,1,932,1,961);a.bezierCurveTo(1,981,22,1E3,57,1E3);a.bezierCurveTo(154,1E3,198,895,216,824);a.lineTo(375,181);a.bezierCurveTo(398,90,420,27,464,28);a.bezierCurveTo(470,28,473,30,473,34);a.bezierCurveTo(473,41,458,47,458,69);a.bezierCurveTo(458,83,471,89,485,89);a.bezierCurveTo(509,89,530,67,530,38);a.bezierCurveTo(530,
18,508,0,473,0);a.bezierCurveTo(368,0,326,120,309,190);a.closePath();a.fill();a.stroke()};a.TextNode.prototype.drawBorderSpecial=function(a,b){a.beginPath();a.setLineDash([1,2]);a.strokeStyle=b;a.lineWidth=1;a.rect(parseInt(this.metrics.x)+.5,parseInt(this.metrics.y-this.metrics.ascent)+.5,this.metrics.w,this.metrics.h);a.stroke();a.setLineDash([])};a.TextNode.prototype.toRTF=function(){var a=[],b=[],c="";this.mergeTextNodes();for(var d=0,e=this.children.length;d<e;d++){var f=this.children[d];"textLineBlock"===
f.nodeType&&(c+=f.toRTFAux(a,b)+(1<e&&d<e-1?"\\par":""))}f="{\\fonttbl";d=0;for(e=a.length;d<e;d++)f+="\\f"+d+"\\fcharset0 "+a[d]+";";a="";if(0<b.length){a="{\\colortbl";d=0;for(e=b.length;d<e;d++)a+=b[d];a+="}"}return"{\\rtf1\\uc0"+(f+"}")+a+c+"}"};a.TextNode.prototype.toRTFAux=function(a,b){for(var c,d,e,g=null,h="",k,m,n,r,C,I=0,G=this.children.length;I<G;I++)k=m="",c=this.children[I],n=this.addToFontTable(c.style.family,a),r=c.style.size,C=this.addToColorTable(c.style.color,b),null===C&&0<b.length&&
(C=this.addToColorTable(f,b)),C!==g&&(k+="\\cf"+C,g=C),n!==d&&(k+="\\f"+n,d=n),r!==e&&(k+="\\fs"+2*r,e=r),c.style.italic&&(k+="\\i",m="\\i0"+m),c.style.bold&&(k+="\\b",m="\\b0"+m),c.style.underline&&(k+="\\ul",m="\\ulnone"+m),c.style.overline&&(k+="\\ol",m="\\olnone"+m),"text"===c.nodeType?(c.value=c.value.replace(/\\{/g,"{").replace(/\\}/g,"}").replace(/{/g,"\\{").replace(/}/g,"\\}"),c=""!==k?k+" "+c.value+m:""!==h&&"}"!==h.charAt(h.length-1)?" "+c.value:c.value,h+=c):"formula"===c.nodeType?h+="{\\*\\mjaformula"+
c.formulaToRTF(d,e,g,a,b)+"}":"componentSpace"===c.nodeType?h+="{\\*\\component\\Space "+c.value+"}":"componentNumCtrl"===c.nodeType&&(h+="{\\*\\component\\NumCtrl "+c.value+"}");return h};a.TextNode.prototype.formulaToRTF=function(a,b,c,d,e){for(var g,h="",l,k,m,n,r=0,q=this.children.length;r<q;r++)l=k="",g=this.children[r],m=this.addToFontTable(g.style.family,d),n=this.addToColorTable(g.style.color,e),null===n&&0<e.length&&(n=this.addToColorTable(f,e)),m!==a&&(l+="\\f"+m,a=m),n!==c&&(l+="\\cf"+
n,"text"!==g.nodeType||"text"===g.nodeType&&""!==g.value)&&(c=n),g.style.italic&&(l+="\\i",k="\\i0"+k),g.style.bold&&(l+="\\b",k="\\b0"+k),g.style.underline&&(l+="\\ul",k="\\ulnone"+k),g.style.overline&&(l+="\\ol",k="\\olnone"+k),"text"===g.nodeType&&""!==g.value?(g.value=g.value.replace(/\\{/g,"{").replace(/\\}/g,"}").replace(/{/g,"\\{").replace(/}/g,"\\}"),tmpRTF=""!==l?l+" "+g.value+k:"}"!==h.charAt(h.length-1)?" "+g.value:g.value,h+=tmpRTF):"dynamicText"===g.nodeType?(g.value=""===g.value?" ":
g.value,h+=l+"{\\expr "+g.value+"\\decimals "+(g.decimals||2)+"\\fixed"+(g.fixed?1:0)+"}"+k):"fraction"===g.nodeType||"radical"===g.nodeType||"index"===g.nodeType||"radicand"===g.nodeType||"sum"===g.nodeType||"integral"===g.nodeType||"limit"===g.nodeType||"from"===g.nodeType||"to"===g.nodeType||"what"===g.nodeType||"element"===g.nodeType?h+="{\\"+g.nodeType+g.formulaToRTF(a,b,c,d,e)+"}":"numerator"===g.nodeType?h+="{\\num"+g.formulaToRTF(a,b,c,d,e)+"}":"denominator"===g.nodeType?h+="{\\den"+g.formulaToRTF(a,
b,c,d,e)+"}":"superIndex"===g.nodeType?h+="{\\supix"+g.formulaToRTF(a,b,c,d,e)+"}":"subIndex"===g.nodeType?h+="{\\subix"+g.formulaToRTF(a,b,c,d,e)+"}":"matrix"===g.nodeType?h+="{\\matrix\\rows "+(g.rows||2)+"\\columns "+(g.columns||2)+g.formulaToRTF(a,b,c,d,e)+"}":"defparts"===g.nodeType&&(h+="{\\defparts\\parts "+(g.parts||2)+g.formulaToRTF(a,b,c,d,e)+"}");return h};a.TextNode.prototype.addToFontTable=function(a,b){var c;a.match(/times/i)?c="Times New Roman":a.match(/courier/i)?c="Courier New":a.match(/arial/i)&&
(c="Arial");a=b.indexOf(c);-1===a&&(a=b.length,b.push(c));return a};a.TextNode.prototype.addToColorTable=function(a,b){if(a){a="\\red"+parseInt(a.substring(1,3),16)+"\\green"+parseInt(a.substring(3,5),16)+"\\blue"+parseInt(a.substring(5,7),16)+";";var c=b.indexOf(a);-1===c&&(c=b.length,b.push(a));return c}return null};a.TextNode.prototype.mergeTextNodes=function(){for(var a=[],b=null,c=0,d=this.children.length;c<d;c++)"text"===this.children[c].nodeType?null!==b&&"text"===b.nodeType&&b.style.equals(this.children[c].style)&&
(this.children[c].value=b.value+this.children[c].value,a.push(b)):this.children[c].mergeTextNodes(),b=this.children[c];c=0;for(d=a.length;c<d;c++)this.removeChild(a[c])};var r={sansserif:{ascent:1854,descent:-434,lineGap:67,capHeight:1409,xHeight:1082,unitsPerEm:2048},serif:{ascent:1825,descent:-443,lineGap:87,capHeight:1341,xHeight:940,unitsPerEm:2048},monospace:{ascent:1705,descent:-615,lineGap:0,capHeight:1349,xHeight:1082,unitsPerEm:2048}};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=String.fromCharCode,k,f,n,e,m,d,c,r,g,b,l,w;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&quote;/g,"''").replace(/&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];k=a.length;f=[];n="";m=e=0;c=a.charAt(0);r=!1;for(g="text";e<k;)d=c,c=a.charAt(e+
1),r?"\\"===c||"{"===c||"}"===c||" "===c||";"===c?(r=!1,n+=d," "===c?(e++,c=a.charAt(e+1),w=!0):w=!1,(b=n.match(/^'([0-9a-f]{2})/))?(l="","text"===g&&(l=f.pop().value),n=l+=h(parseInt(b[1],16))+n.substring(3)):(b=n.match(/^u[0-9]+/))?(l="","text"===g&&(l=f.pop().value),n=l+=h(b[0].substring(1))):("{"===n||"}"===n||"\\"==d?(f.push({type:"text",value:n+(w?" ":"")}),g="text"):(f.push({type:"controlWord",value:n}),g="controlWord"),n="")):"{"==d||"}"==d||"\\"==d?(r=!1,f.push({type:"text",value:d}),g="text"):
n+=d:"\\"===d?(r=!0,""!==n&&(f.push({type:"text",value:n}),g="text",n="")):"{"===d?(m++,""!==n&&(f.push({type:"text",value:n}),n=""),f.push({type:"openBlock",value:m}),g="openBlock"):"}"===d?(""!==n&&(f.push({type:"text",value:n}),n=""),f.push({type:"closeBlock",value:m}),g="closeBlock",m--):n+=d,e++;""!==n&&f.push({type:"text",value:n});return f};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=Math.max,k,f,n,e,m,d,c,r,g,b,l,w,q,u,x,p,v,y,A,C,I,G,K,E,z,F,L,N,M;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=function(B){k=this.tokenizer.tokenize(B);f={};e=2;if("openBlock"===k[0].type&&"fonttbl"===k[1].value){for(n=k[0].value;"closeBlock"!==k[e].type&&k[e].value!==n;)f[k[e].value]=k[e+2].value.substring(0,k[e+2].value.length-1),e+=3;e++}m={};d=0;if("openBlock"===k[e].type&&"colortbl"===
k[e+1].value){n=k[e++].value;for(e++;"closeBlock"!==k[e].type&&k[e].value!==n;)c=parseInt(k[e++].value.substring(3)).toString(16),r=parseInt(k[e++].value.substring(5)).toString(16),g=parseInt(k[e++].value.substring(4)).toString(16),";"===k[e].value&&e++,m[d++]="#"+(2>c.length?"0"+c:c)+(2>r.length?"0"+r:r)+(2>g.length?"0"+g:g);e++}u=q=w=null;C=A=y=v=p=x=!1;I=[new a.TextStyle];G=I[0];E=K=-1;z=[];N=L=F=!1;b=M=new a.TextNode("","textBlock",G,this.evaluator);l=new a.TextNode("","textLineBlock",G,this.evaluator);
b.addChild(l);M.stableWidth=!0;M.hasFormula=!1;B=e;for(var D=k.length;B<D;B++){if("controlWord"==k[B].type)if(f[k[B].value])G.set({family:f[k[B].value]});else if(k[B].value.match(/^fs(\d+)/))G.set({size:parseInt(k[B].value.match(/^fs(\d+)/)[1]/2)});else if("b"==k[B].value)G.set({bold:!0}),0<z.length&&z[z.length-1].style.set({bold:!0});else if("b0"==k[B].value)G.set({bold:!1}),0<z.length&&z[z.length-1].style.set({bold:!1});else if("i"==k[B].value)G.set({italic:!0}),0<z.length&&z[z.length-1].style.set({italic:!0});
else if("i0"==k[B].value)G.set({italic:!1}),0<z.length&&z[z.length-1].style.set({italic:!1});else if("ul"==k[B].value)G.set({underline:!0}),0<z.length&&z[z.length-1].style.set({underline:!0});else if("ulnone"==k[B].value)G.set({underline:!1}),0<z.length&&z[z.length-1].style.set({underline:!1});else if("ol"==k[B].value)G.set({overline:!0}),0<z.length&&z[z.length-1].style.set({overline:!0});else if("olnone"==k[B].value)G.set({overline:!1}),0<z.length&&z[z.length-1].style.set({overline:!1});else if(k[B].value.match(/^cf(\d+)/))G.set({color:m[parseInt(k[B].value.substring(2))]}),
0<z.length&&(z[z.length-1].style.color=G.color);else if("par"==k[B].value){b=new a.TextNode("","textLineBlock",G.clone(),this.evaluator);if("textBlock"!=l.nodeType)for(l=l.parent;"textBlock"!=l.nodeType;)l=l.parent;l.addChild(b);l=b}else if("mjaformula"==k[B].value)M.hasFormula=!0,E=K,x=!0,b=new a.TextNode("","formula",G.clone(),this.evaluator),l.addChild(b),l=b,z[z.length-1]=b;else if("fraction"==k[B].value||"radicand"==k[B].value||"radical"==k[B].value||"what"==k[B].value||"sum"==k[B].value||"integral"==
k[B].value||"limit"==k[B].value){var J=z[z.length-2].style.clone();b=new a.TextNode("",k[B].value,J,this.evaluator);z[z.length-2].addChild(b);z[z.length-1]=b}else"index"==k[B].value?(J=z[z.length-2].style.clone(),J.size=h(parseInt(J.size-.5*J.size),8),b=new a.TextNode("",k[B].value,J,this.evaluator),z[z.length-2].addChild(b),z[z.length-1]=b):"to"==k[B].value||"from"==k[B].value?(J=z[z.length-2].style.clone(),J.size=h(parseInt(J.size-.2*J.size),8),b=new a.TextNode("",k[B].value,J,this.evaluator),z[z.length-
2].addChild(b),z[z.length-1]=b):"num"==k[B].value||"den"==k[B].value?(J=z[z.length-2].style.clone(),J.size=h(Math.round(J.size-.1*J.size),8),"num"==k[B].value?b=new a.TextNode("","numerator",J,this.evaluator):"den"==k[B].value&&(b=new a.TextNode("","denominator",J,this.evaluator)),z[z.length-2].addChild(b),z[z.length-1]=b):"subix"==k[B].value||"supix"==k[B].value?(J=z[z.length-2].style.clone(),J.size=h(Math.floor(J.size-.33*J.size),8),"subix"==k[B].value?b=new a.TextNode("","subIndex",J,this.evaluator):
"supix"==k[B].value&&(b=new a.TextNode("","superIndex",J,this.evaluator)),b.originalStyle=z[z.length-2].style.clone(),z[z.length-2].addChild(b),z[z.length-1]=b):"defparts"==k[B].value||"matrix"==k[B].value||"element"==k[B].value?(J=z[z.length-2].style.clone(),b=new a.TextNode("",k[B].value,J,this.evaluator),z[z.length-2].addChild(b),z[z.length-1]=b,"defparts"==k[B].value?u=b:"matrix"==k[B].value&&(q=b)):"parts"==k[B].value?C=!0:"rows"==k[B].value?y=!0:"columns"==k[B].value?A=!0:"expr"==k[B].value?
(M.stableWidth=!1,p=!0):"decimals"==k[B].value?v=!0:"fixed1"==k[B].value?w.fixed=!0:"fixed0"==k[B].value?w.fixed=!1:"component"!=k[B].value&&("NumCtrl"==k[B].value?F=!0:"Space"==k[B].value?L=!0:"hyperlink"==k[B].value&&(N=!0));if("text"==k[B].type)if(C)u.parts=parseInt(k[B].value),C=!1;else if(y)q.rows=parseInt(k[B].value),y=!1;else if(A)q.columns=parseInt(k[B].value),A=!1;else if(v)w.decimals=this.evaluator.parser.parse(k[B].value+""),v=!1;else if(N){textContent=k[B].value.split("|")[0];J=G.clone();
b=new a.TextNode(textContent,"hyperlink",J,this.evaluator);b.URL=k[B].value.split("|")[1];if("textLineBlock"!=l.nodeType)for(l=l.parent;"textLineBlock"!=l.nodeType;)l=l.parent;l.addChild(b);N=!1}else if(F)b=new a.TextNode(k[B].value,"componentNumCtrl",G.clone(),this.evaluator),l.addChild(b),F=!1;else if(L)b=new a.TextNode(k[B].value,"componentSpace",G.clone(),this.evaluator),l.addChild(b),L=!1;else if(p)J=z[z.length-2].style.clone(),textContent=this.evaluator.parser.parse(k[B].value),b=new a.TextNode(textContent,
"dynamicText",J,this.evaluator),z[z.length-2].addChild(b),w=z[z.length-1]=b,p=!1;else if(p||x)!p&&x&&(textContent=k[B].value,b=new a.TextNode(textContent,"text",z[z.length-1].style.clone(),this.evaluator),z[z.length-1].addChild(b));else{textContent=k[B].value;b=new a.TextNode(textContent,"text",G.clone(),this.evaluator);if("textLineBlock"!=l.nodeType)for(l=l.parent;"textLineBlock"!=l.nodeType;)l=l.parent;l.addChild(b)}else if("openBlock"==k[B].type)K=k[B].value,G=G.clone(),I.push(G),z.push(null);
else if("closeBlock"==k[B].type)k[B].value==E&&(E=-1,x=!1,l=l.parent),I.pop(),G=I[I.length-1],z.pop();else if("("==k[B].type||")"==k[B].type)J=z[z.length-1].style.clone(),J.italic="",b=new a.TextNode(k[B].type,"mathSymbol",J,this.evaluator),z[z.length-1].addChild(b);else if("+"==k[B].type||"-"==k[B].type||"*"==k[B].type||"="==k[B].type)b=new a.TextNode(k[B].type,"mathSymbol",z[z.length-1].style.clone(),this.evaluator),z[z.length-1].addChild(b)}return M.normalize()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m,d,c,r,g,b;a.Space=function(b,c){this.parent=b;k=this.evaluator=this.parent.evaluator;f=k.parser;this.id="";this.values=c;this.type="R2";this.xExpr=f.parse("0");this.yExpr=f.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=f.parse("1");this.fixed=2===b.version;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";this.bg_display="topleft";
this.background=new a.Color(/DescartesJS.class/i.test(b.code)||b.arquimedes?"f0f8fa":"ffffff");this.net=2!=b.version?new a.Color("c0c0c0"):"";this.net10=2!=b.version?new a.Color("808080"):"";this.axes=2!=b.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.y_axis=this.x_axis=2!=b.version?"":" ";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=0;this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=
b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.initSpace()};a.Space.prototype.initSpace=function(){h=this.parent;k=this.evaluator;n=this.id;this.resizable||(this.displaceRegionNorth=h.displaceRegionNorth||0,this.displaceRegionSouth=h.displaceRegionSouth||0,this.displaceRegionEast=h.displaceRegionEast||0,this.displaceRegionWest=h.displaceRegionWest||0,c=parseInt(h.container.width),
d=parseInt(h.container.height),void 0!=this.wExpr&&(this.w=parseInt(c-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.wExpr)/100),void 0!=this.hExpr&&(this.h=parseInt(d-this.displaceRegionNorth-this.displaceRegionSouth)*parseFloat(this.hExpr)/100),void 0!=this.xPercentExpr&&(this.xExpr=k.parser.parse((parseInt(c-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.xPercentExpr)/100).toString())),void 0!=this.yPercentExpr&&(this.yExpr=k.parser.parse((parseInt(d-this.displaceRegionNorth-
this.displaceRegionSouth)*parseFloat(this.yPercentExpr)/100).toString())),this.x=k.eval(this.xExpr)+this.displaceRegionWest,this.y=k.eval(this.yExpr)+this.plecaHeight+this.displaceRegionNorth,this.container&&(this.container.style.left=this.x+"px",this.container.style.top=this.y+"px"),0<=this.y?(e=d-this.y,this.h>e&&(this.h=e)):(e=this.h+this.y,this.h=e>=d?d:e),0<=this.x?(m=c-this.x,this.w>m&&(this.w=m)):(m=this.w+this.x,this.w=m>=c?c:m));""==this.imageSrc&&/vacio.gif$/i.test(this.imageSrc.trim())||
(this.image=h.getImage(this.imageSrc));this.OxExpr&&(g=this.OxExpr,"%"===g[g.length-1]?this.Ox=this.w*parseFloat(g)/100:(r=parseFloat(g),r!=g&&(r=0),this.Ox=r));this.OyExpr&&(b=this.OyExpr,"%"===b[b.length-1]?this.Oy=this.h*parseFloat(b)/100:(r=parseFloat(b),r!=b&&(r=0),this.Oy=r));""!==this.id&&2!==h.version?(k.setVariable(n+"._w",this.w),k.setVariable(n+"._h",this.h),k.setVariable(n+".escala",this.scale),k.setVariable(n+".Ox",this.Ox),k.setVariable(n+".Oy",this.Oy),k.setVariable(n+".mouse_x",0),
k.setVariable(n+".mouse_y",0),k.setVariable(n+".mouse_pressed",0),k.setVariable(n+".mouse_clicked",0),k.setVariable(n+".clic_izquierdo",0)):(r=k.getVariable("_w"),void 0===r&&(r=this.w),k.setVariable("_w",r),r=k.getVariable("_h"),void 0===r&&(r=this.h),k.setVariable("_h",r),r=k.getVariable("escala"),void 0===r&&(r=this.scale),k.setVariable("escala",r),r=k.getVariable("Ox"),void 0===r&&(r=this.Ox),k.setVariable("Ox",r),r=k.getVariable("Oy"),void 0===r&&(r=this.Oy),k.setVariable("Oy",r),k.setVariable("mouse_x",
0),k.setVariable("mouse_y",0),k.setVariable("mouse_pressed",0),k.setVariable("mouse_clicked",0),k.setVariable("clic_izquierdo",0),2==h.version&&""===this.x_axis&&""===this.y_axis&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a,b){"R2"===this.type&&b||"R3"===this.type&&!b||(a.background&&"R3"!==this.type?this.backGraphics.push(a):this.graphics.push(a))};a.Space.prototype.clearClick=
function(){this.evaluator.setVariable(this.mclickedString,0);this.evaluator.setVariable(this.mclicizquierdoString,0)};a.Space.prototype.getRelativeX=function(a){return((a>>0)-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-(a>>0)+this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h;a.SpaceExternal=function(a){h=this;h.parent=a;h.width=228;h.vSpace=25;h.container=document.createElement("div");h.container.setAttribute("style","box-sizing:border-box;border-style:ridge;border-width:5px;border-color:gray;box-shadow:#000 0 0 25px 5px;overflow-y:scroll;overflow-x:hidden;position:fixed;left:0;top:0;z-index:10000;width:"+(h.width+27)+"px;height:460px;background-color:#63b4fb");h.movable=document.createElement("div");h.movable.setAttribute("style",
" position:absolute;left:0;top:0;width:"+(h.width+27)+"px;height:"+h.vSpace+"px;line-height:"+h.vSpace+"px;background-color:#ddd;cursor:move;padding-left:75px;font-family:Sans-Serif;font-size:18px;");h.movable.innerHTML="Descartes";h.container.appendChild(h.movable);h.ctrs=[]};a.SpaceExternal.prototype.init=function(){function k(d){h.newPos=a.getCursorPosition(d,document.body);h.container.style.left=h.initialPosition.x+(h.newPos.x-h.oldPos.x)*a.cssScale+"px";h.container.style.top=h.initialPosition.y+
(h.newPos.y-h.oldPos.y)*a.cssScale+"px"}function f(a){a.preventDefault();document.body.removeEventListener("mousemove",k);document.body.removeEventListener("mouseup",f)}document.body.appendChild(this.container);h=this;for(var n=h.parent.evaluator.parser,e=0,m=h.ctrs.length;e<m;e++)h.ctrs[e].expresion=n.parse("(0,"+(h.vSpace+23+35*e)+","+h.width+",35)"),h.ctrs[e].update();h.numCtr=m;e=new a.Button(h.parent,{region:"external",name:"english"==h.language?"about":"cr\u00e9ditos",font_size:n.parse("15"),
expresion:n.parse("(0,"+h.vSpace+","+h.width/2+",25)")});e.actionExec={execute:a.showAbout};e.update();(new a.Button(h.parent,{region:"external",name:"config",font_size:n.parse("15"),action:"config",expresion:n.parse("("+h.width/2+","+h.vSpace+","+h.width/2+",25)")})).update();(new a.Button(h.parent,{region:"external",name:"english"==h.language?"init":"inicio",font_size:n.parse("15"),action:"init",expresion:n.parse("(0,"+(h.vSpace+23+35*m)+","+h.width/2+",25)")})).update();(new a.Button(h.parent,
{region:"external",name:"english"==h.language?"clear":"limpiar",font_size:n.parse("15"),action:"clear",expresion:n.parse("("+h.width/2+","+(h.vSpace+23+35*m)+","+h.width/2+",25)")})).update();n=new a.Button(h.parent,{region:"external",name:"english"==h.language?"close":"cerrar",font_size:n.parse("15"),expresion:n.parse("("+h.width/4+","+(h.vSpace+46+35*m)+","+h.width/2+",25)")});n.update();n.btn.addEventListener("click",function(a){h.hide()});h.setPositionAndSize();h.movable.addEventListener("mousedown",
function(d){d.preventDefault();h.oldPos=a.getCursorPosition(d,document.body);h.initialPosition={x:h.container.offsetLeft,y:h.container.offsetTop};document.body.addEventListener("mousemove",k);document.body.addEventListener("mouseup",f)});h.hide()};a.SpaceExternal.prototype.addCtr=function(a){this.ctrs.push(a)};a.SpaceExternal.prototype.show=function(){this.setPositionAndSize();this.container.style.display="block"};a.SpaceExternal.prototype.hide=function(){this.container.style.display="none"};a.SpaceExternal.prototype.setPositionAndSize=
function(){h=this;var a=h.vSpace+46+35*h.numCtr+25+10;h.container.style.left=Math.max(parseInt(window.innerWidth-h.width)/2,0)+"px";h.container.style.top="5px";h.container.style.height=window.innerHeight<h.vSpace+75?h.vSpace+75+"px":a>window.innerHeight-10?window.innerHeight-10:a+"px"};return a}(descartesJS||{});
descartesJS=function(a){var h,k;if(a.loadLib)return a;var f=Math.floor,n=Math.round,e=2*Math.PI,m=a.convertFont("SansSerif,PLAIN,12"),d=a.convertFont("Monospaced,PLAIN,12"),c,r,g,b,l,w,q,u,x,p,v,y,A,C,I,G,K,E,z,F,L,N,M,B,D,J,H,P,O,Q;a.Space2D=function(b,d){a.Space.call(this,b,d);c=this;c.ratio=b.ratio;c.canvas=document.createElement("canvas");c.canvas.setAttribute("id",c.id+"_canvas");c.canvas.setAttribute("class","DescartesSpace2DCanvas");c.backCanvas=document.createElement("canvas");c.backCanvas.setAttribute("id",
c.id+"_background");c.canvas.style.zIndex=c.zIndex;c.canvas.width=c.backCanvas.width=c.w*c.ratio;c.canvas.height=c.backCanvas.height=c.h*c.ratio;c.canvas.style.width=c.backCanvas.style.width=c.w+"px";c.canvas.style.height=c.backCanvas.style.height=c.h+"px";c.ctx=c.canvas.getContext("2d");c.backCtx=c.backCanvas.getContext("2d");c.ctx.imageSmoothingEnabled=c.backCtx.imageSmoothingEnabled=!1;c.graphicControlContainer=document.createElement("div");c.graphicControlContainer.setAttribute("id",c.id+"_graphicControls");
c.graphicControlContainer.setAttribute("style","position:absolute;left:0;top:0;z-index:"+c.zIndex+";");c.numericalControlContainer=document.createElement("div");c.numericalControlContainer.setAttribute("id",c.id+"_numericalControls");c.numericalControlContainer.setAttribute("style","position:absolute;left:0;top:0;z-index:"+c.zIndex+";");c.container=document.createElement("div");c.container.setAttribute("id",c.id);c.container.setAttribute("class","DescartesSpace2DContainer");c.container.setAttribute("style",
"left:"+c.x+"px;top:"+c.y+"px;z-index:"+c.zIndex+";");c.parent.arquimedes&&"#f0f8fa"===c.background.getColor()&&(c.container.style.boxShadow="0 0 5px 0 #b8c4c8");c.container.appendChild(c.backCanvas);c.container.appendChild(c.canvas);c.container.appendChild(c.graphicControlContainer);c.container.appendChild(c.numericalControlContainer);b.container.insertBefore(c.container,b.loader);d=c.id+".image";c.parent.images[d]=c.canvas;c.parent.images[d].ready=1;c.parent.images[d].complete=c.parent.images[d].canvas=
!0;c.evaluator.setVariable(d,d);d=c.id+".back";c.parent.images[d]=c.backCanvas;c.parent.images[d].ready=1;c.parent.images[d].complete=c.parent.images[d].canvas=!0;c.evaluator.setVariable(d,d);d=""!==c.id&&2!==b.version?c.id+".":"";c.OxStr=d+"Ox";c.OyStr=d+"Oy";c.scaleStr=d+"escala";c.wStr=d+"_w";c.hStr=d+"_h";c.mxStr=d+"mouse_x";c.myStr=d+"mouse_y";c.mpressedStr=d+"mouse_pressed";c.mclickedStr=d+"mouse_clicked";c.mclickIzqStr=d+"clic_izquierdo";c.click=0;c.resizable&&(c.wModExpr=b.evaluator.parser.parse(c.wModExpr),
c.hModExpr=b.evaluator.parser.parse(c.hModExpr));"descartesJS_stage"!==c.id?c.addEvents():(c.stage_height=0,c.canvas.oncontextmenu=function(a){return!1})};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){c=this;this.initSpace();c.canvas&&(c.old_w=c.w,c.old_h=c.h,c.canvas.width=c.backCanvas.width=c.w*c.ratio,c.canvas.height=c.backCanvas.height=c.h*c.ratio,c.canvas.style.width=c.backCanvas.style.width=c.w+"px",c.canvas.style.height=c.backCanvas.style.height=c.h+"px");if("descartesJS_stage"===
c.id&&(c.setArquimedesHeight(),a.TextController&&!c.textController)){var b=null;c.backGraphics[0]&&c.backGraphics[0].text&&c.backGraphics[0].text.textNodes&&(b=c.backGraphics[0].text.textNodes);b&&(c.textController=new a.TextController(this,c.container,c.backCanvas,b,{fontFamily:"Times New Roman",fontSize:"30px",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",decimals:2,fixed:!1},"000000"))}};a.Space2D.prototype.update=function(a){c=this;r=c.evaluator;g=c.parent;c.resizable||(r.setVariable(c.wStr,
c.w),r.setVariable(c.hStr,c.h));c.drawIfValue=0<r.eval(c.drawif);if(c.drawIfValue){c.resizable&&(O=c.evaluator.eval(c.wModExpr),Q=c.evaluator.eval(c.hModExpr),c.old_w!=O||c.old_h!=Q)&&(c.w=O,c.h=Q,c.w_2=c.w/2,c.h_2=c.h/2,r.setVariable(c.wStr,c.w),r.setVariable(c.hStr,c.h),c.old_w=c.w,c.old_h=c.h,c.canvas.width=c.backCanvas.width=c.w*c.ratio,c.canvas.height=c.backCanvas.height=c.h*c.ratio,c.canvas.style.width=c.backCanvas.style.width=c.w+"px",c.canvas.style.height=c.backCanvas.style.height=c.h+"px",
a=!0);l=c.x!==r.eval(c.xExpr)+c.displaceRegionWest;w=c.y!==r.eval(c.yExpr)+g.plecaHeight+c.displaceRegionNorth;c.spaceChange=a||l||w||c.drawBefore!==c.drawIfValue||c.Ox!==r.getVariable(c.OxStr)||c.Oy!==r.getVariable(c.OyStr)||c.scale!==r.getVariable(c.scaleStr)||c.backColor!==c.background.getColor();c.x=l?r.eval(c.xExpr)+c.displaceRegionWest:c.x;c.y=w?r.eval(c.yExpr)+g.plecaHeight+c.displaceRegionNorth:c.y;c.Ox=r.getVariable(c.OxStr);c.Oy=r.getVariable(c.OyStr);c.scale=r.getVariable(c.scaleStr);c.drawBefore=
c.drawIfValue;c.scale=Math.max(1E-6,Math.min(1E6,c.scale));r.setVariable(c.scaleStr,c.scale);if(l||w)c.container.style.left=c.x+"px",c.container.style.top=c.y+"px";c.container.style.display="block";c.drawTrace=!c.spaceChange&&(!c.fixed&&!c.click||c.fixed);c.spaceChange&&(c.backCtx.setTransform(c.ratio,0,0,c.ratio,0,0),c.drawBackground());c.ctx.setTransform(c.ratio,0,0,c.ratio,0,0);c.draw()}else c.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){c=this;r=c.evaluator;b=
c.backCtx;b.clearRect(0,0,c.backCanvas.width,c.backCanvas.height);c.backColor=c.background.getColor();b.fillStyle=c.backColor;b.fillRect(0,0,c.backCanvas.width,c.backCanvas.height);c.image&&""!=c.image.src&&c.image.ready&&c.image.complete&&("topleft"===c.bg_display?b.drawImage(c.image,0,0):"stretch"===c.bg_display?b.drawImage(c.image,0,0,c.w,c.h):"patch"===c.bg_display?(b.fillStyle=b.createPattern(c.image,"repeat"),b.fillRect(0,0,c.w,c.h)):"imgcenter"===c.bg_display&&b.drawImage(c.image,(c.w-c.image.width)/
2,(c.h-c.image.height)/2));u=c.scale;x=0;for(p=0>c.w+c.h?0:c.w+c.h;u>p;)u/=10,x++;for(;u<p/10;)u*=10;b.lineWidth=1;""!==c.net&&(b.strokeStyle=c.net.getColor(),c.drawMarks(b,u/10,-1));if(2!==c.parent.version&&""!==c.net10||2===c.parent.version&&""!==c.net&&""!==c.net10)b.strokeStyle=c.net10.getColor(),c.drawMarks(b,u,-1);if(""!==c.axes){var a="";"no"==c.x_axis&&(a+="x");"no"==c.y_axis&&(a+="y");b.strokeStyle=c.axes.getColor();b.beginPath();"no"==c.x_axis||""===c.x_axis&&2===c.parent.version||(b.moveTo(0,
f(c.h/2+c.Oy)+.5),b.lineTo(c.w,f(c.h/2+c.Oy)+.5));"no"==c.y_axis||""===c.y_axis&&2===c.parent.version||(b.moveTo(f(c.w/2+c.Ox)+.5,0),b.lineTo(f(c.w/2+c.Ox)+.5,c.h));b.lineWidth=1.2;b.stroke();b.lineWidth=1;c.drawMarks(b,u,4,a);c.drawMarks(b,u/2,2,a);c.drawMarks(b,u/10,1,a)}if(""!==c.x_axis||""!==c.y_axis)b.fillStyle=""!==c.axes?c.axes.getColor():"#000",b.font=m,b.textAlign="right",b.textBaseline="alphabetic","no"!=c.x_axis&&b.fillText(c.x_axis,f(c.w)-2,f(c.h/2+c.Oy)+12),"no"!=c.y_axis&&b.fillText(c.y_axis,
f(c.w/2+c.Ox)-2,12);c.numbers&&""!=c.axes&&(b.fillStyle=c.axes.getColor(),b.font=m,b.textAlign="start",b.textBaseline="bottom",u>(c.w+c.h)/2?c.drawNumbers(b,u/5,u<=c.scale?x+1:x):u>(c.w+c.h)/4?c.drawNumbers(b,u/2,u<=c.scale?x+1:x):c.drawNumbers(b,u,x));a=0;for(var d=this.backGraphics.length;a<d;a++)this.backGraphics[a].draw()};a.Space2D.prototype.setArquimedesHeight=function(){this.update(!0);if(0<this.backGraphics.length&&this.backGraphics[0].text.textNodes.metrics.h!==this.stage_height){this.stage_height=
this.backGraphics[0].text.textNodes.metrics.h;var a=1<this.backGraphics.length?this.backGraphics[1].text.textNodes.metrics.h+25:0;this.h=this.stage_height+a+75;1<this.backGraphics.length&&(this.backGraphics[1].expresion=this.evaluator.parser.parse("["+this.backGraphics[1].exprX+","+(this.stage_height+a)+"]"));2<this.backGraphics.length&&(this.backGraphics[2].expresion=this.evaluator.parser.parse("["+this.backGraphics[2].exprX+","+(this.stage_height+a+25)+"]"));this.canvas.width=this.backCanvas.width=
this.w*this.ratio;this.canvas.height=this.backCanvas.height=this.h*this.ratio;this.canvas.style.width=this.backCanvas.style.width=this.w+"px";this.canvas.style.height=this.backCanvas.style.height=this.h+"px";this.parent.container.style.height=this.h+this.plecaHeight+"px";this.update(!0)}};a.Space2D.prototype.draw=function(){c=this;b=c.ctx;b.clearRect(0,0,c.canvas.width,c.canvas.height);for(var a=0,g=c.graphics.length;a<g;a++)q=c.graphics[a],""!==q.trace&&c.drawTrace&&q.drawTrace(),q.draw();a=0;for(g=
c.graphicsCtr.length;a<g;a++)c.graphicsCtr[a].draw();""!=c.text&&c.click&&"L"===c.whichBtn&&(b.save(),b.fillStyle=c.text.getColor(),b.strokeStyle=b.fillStyle,b.lineWidth=1,b.font=d,b.textAlign="center",b.textBaseline="alphabetic",L=1>=c.scale?c.mouse_x.toFixed(0):c.mouse_x.toFixed(c.scale.toString().length),N=1>=c.scale?c.mouse_y.toFixed(0):c.mouse_y.toFixed(c.scale.toString().length),M="("+L+","+N+")",B=f(b.measureText(M).width/2),D=c.getAbsoluteX(c.mouse_x),J=c.getAbsoluteY(c.mouse_y),H=f(D),P=
f(J-10),H+B>c.w?H=c.w-B:0>H-B&&(H=B),P+1>c.h?P=c.h:0>P-14&&(P=15),b.fillText(M,H,P),b.beginPath(),b.arc(D,J,2.5,0,e,!0),b.stroke(),b.restore())};a.Space2D.prototype.drawMarks=function(a,b,c,d){v=this.w;y=this.h;z=K=0;E=v;F=y;I=f(v/2+this.Ox);G=f(y/2+this.Oy);0<=c&&(K=I-c,E=I+c,z=G-c,F=G+c);a.beginPath();if(!d||d&&!d.match("x"))for(c=-n(I/b);(A=I+n(c*b))<v;c++)a.moveTo(A+.5,z+.5),a.lineTo(A+.5,F+.5);if(!d||d&&!d.match("y"))for(c=-n(G/b);(C=G+n(c*b))<y;c++)a.moveTo(K+.5,C+.5),a.lineTo(E+.5,C+.5);a.stroke()};
a.Space2D.prototype.drawNumbers=function(a,b,c){v=this.w;y=this.h;I=f(v/2+this.Ox);G=f(y/2+this.Oy);for(c=-n(I/b);(A=I+n(c*b))<v;c++)a.fillText(parseFloat((c*b/this.scale).toFixed(4)),A+1,G-2);for(c=-n(G/b);(C=G+n(c*b))<y;c++)0!==parseFloat(-c*b/this.scale)&&a.fillText(parseFloat((-c*b/this.scale).toFixed(4)),I+5,C+5)};a.Space2D.prototype.addEvents=function(){function b(a){window.focus();document.activeElement.blur();if(g.evaluator.variables[g.id+".DESCARTESJS_no_fixed"]||!g.fixed||g.sensitive_to_mouse_movements)g.click=
0,g.evaluator.setVariable(g.mpressedStr,0),g.evaluator.setVariable(g.mclickedStr,1),g.evaluator.setVariable(g.mclickIzqStr,1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",b),a.stopPropagation(),a.preventDefault(),g.parent.update()}function c(b){document.activeElement.blur();window.focus();b.stopPropagation();b.preventDefault();g.click=0;g.evaluator.setVariable(g.mpressedStr,0);g.evaluator.setVariable(g.mclickedStr,1);g.evaluator.setVariable(g.mclickIzqStr,1);"R"===
g.whichBtn&&(window.removeEventListener("mousemove",e),g.posZoom==g.posZoomNew&&a.showConfig&&(g.parent.externalSpace.show(),g.posZoom=!1,g.posZoomNew=!0));window.removeEventListener("mousemove",f);window.removeEventListener("mouseup",c);g.parent.deactivateGraphiControls();g.parent.update()}function d(b){g.posAnte=a.getCursorPosition(b,g.container);g.mouse_x=g.getRelativeX(g.posAnte.x);g.mouse_y=g.getRelativeY(g.posAnte.y);g.evaluator.setVariable(g.mxStr,g.mouse_x);g.evaluator.setVariable(g.myStr,
g.mouse_y);g.evaluator.setVariable(g.mclickedStr,0);g.evaluator.setVariable(g.mclickIzqStr,0);g.parent.update()}function e(b){b.preventDefault();g.posZoomNew=a.getCursorPosition(b,g.container).y;g.evaluator.setVariable(g.scaleStr,g.tempScale+g.tempScale/45*((g.posZoom-g.posZoomNew)/10));g.parent.update()}function f(b){b.preventDefault();b.stopPropagation();g.fixed||(g.posNext=a.getCursorPosition(b,g.container),h=g.posAnte.x-g.posNext.x,k=g.posAnte.y-g.posNext.y,g.evaluator.setVariable(g.OxStr,g.Ox-
h),g.evaluator.setVariable(g.OyStr,g.Oy-k));d(b)}var g=this;g.posZoom=g.posZoomNew=null;g.canvas.oncontextmenu=function(a){return!1};this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",d);this.canvas.addEventListener("touchstart",function(a){window.focus();document.activeElement.blur();if(g.evaluator.variables[g.id+".DESCARTESJS_no_fixed"]||!g.fixed||g.sensitive_to_mouse_movements)g.parent.clearClick(),g.click=1,g.evaluator.setVariable(g.mpressedStr,1),g.evaluator.setVariable(g.mclickedStr,
0),g.evaluator.setVariable(g.mclickIzqStr,0),g.parent.deactivateGraphiControls(),d(a),window.addEventListener("touchmove",f),window.addEventListener("touchend",b),a.stopPropagation(),a.preventDefault()});this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",d);this.canvas.addEventListener("mousedown",function(b){window.focus();document.activeElement.blur();b.stopPropagation();b.preventDefault();g.parent.clearClick();g.click=1;g.parent.deactivateGraphiControls();g.whichBtn=a.whichBtn(b);
"R"===g.whichBtn?(window.addEventListener("mouseup",c),g.posZoom=a.getCursorPosition(b,g.container).y,g.posZoomNew=g.posZoom,g.fixed||(g.tempScale=g.scale,window.addEventListener("mousemove",e))):"L"===g.whichBtn&&(g.evaluator.setVariable(g.mpressedStr,1),g.evaluator.setVariable(g.mclickedStr,0),g.evaluator.setVariable(g.mclickIzqStr,0),d(b),window.addEventListener("mousemove",f),window.addEventListener("mouseup",c))});this.canvas.addEventListener("dblclick",function(a){});document.addEventListener("visibilitychange",
function(a){c(a)})};return a}(descartesJS||{});
descartesJS=function(a){var h,k,f;function n(b,c){D=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));J=a.add3D(b,a.scalarProduct3D(D,-2));H=a.norm3D(J);return 0!==H?a.scalarProduct3D(J,1/H):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var e=Math.floor,m=Math.max,d=Math.cos,c=Math.sin,r,g,b,l,w,q,u,x,p,v,y,A,C,I,G,K,E=[],z,F,L,N,M,B,D,J,H,P,O;a.Space3D=function(c,d){a.Space.call(this,c,d);b=this;b.backCanvas=document.createElement("canvas");b.backCanvas.setAttribute("id",b.id+"_background");
b.backCanvas.setAttribute("width",b.w+"px");b.backCanvas.setAttribute("height",b.h+"px");b.canvas=document.createElement("canvas");b.canvas.setAttribute("id",b.id+"_canvas");b.canvas.setAttribute("width",b.w+"px");b.canvas.setAttribute("height",b.h+"px");b.canvas.setAttribute("class","DescartesSpace3DCanvas");b.canvas.setAttribute("style","z-index: "+b.zIndex+";");b.ctx=b.canvas.getContext("2d");b.ctx.imageSmoothingEnabled=!1;d=b.id+".image";b.parent.images[d]=b.canvas;b.parent.images[d].ready=1;
b.parent.images[d].complete=!0;b.parent.images[d].canvas=!0;b.evaluator.setVariable(d,d);b.graphicControlContainer=document.createElement("div");b.graphicControlContainer.setAttribute("id",b.id+"_graphicControls");b.graphicControlContainer.setAttribute("style","position:absolute;left:0px;top:0px;z-index:"+b.zIndex+";");b.numericalControlContainer=document.createElement("div");b.numericalControlContainer.setAttribute("id",b.id+"_numericalControls");b.numericalControlContainer.setAttribute("style",
"position:absolute;left:0px;top:0px;z-index:"+b.zIndex+";");b.container=document.createElement("div");b.container.setAttribute("id",b.id);b.container.setAttribute("class","DescartesSpace3DContainer");b.container.setAttribute("style","left:"+b.x+"px;top:"+b.y+"px;z-index:"+b.zIndex+";");b.container.appendChild(b.backCanvas);b.container.appendChild(b.canvas);b.container.appendChild(b.graphicControlContainer);b.container.appendChild(b.numericalControlContainer);c.container.insertBefore(b.container,c.loader);
b.eye={x:0,y:0,z:0};b.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}];d=0;for(var e=b.lights.length;d<e;d++)b.lights[d]=a.normalize3D(b.lights[d]);b.light3={x:0,y:0,z:0};b.intensity=[.4,.5,.3,0];b.userIntensity=0;b.dim=1;b.tmpIntensity=[];b.OxStr=b.id+".Ox";b.OyStr=b.id+".Oy";b.scaleStr=b.id+".escala";b.wStr=b.id+"._w";b.hStr=b.id+"._h";b.obsStr=b.id+".observador";b.ojoXStr=b.id+".Ojo.x";b.ojoYStr=b.id+".Ojo.y";b.ojoZStr=b.id+".Ojo.z";b.rotZStr=b.id+".rot.z";b.rotYStr=b.id+
".rot.y";b.userIDimStr=b.id+".userIlum.dim";b.userIIStr=b.id+".userIlum.I";b.userIxStr=b.id+".userIlum.x";b.userIyStr=b.id+".userIlum.y";b.userIzStr=b.id+".userIlum.z";b.evaluator.setVariable(b.rotZStr,0);b.evaluator.setVariable(b.rotYStr,0);b.evaluator.setVariable(b.userIDimStr,b.dim);b.evaluator.setVariable(b.userIIStr,b.userIntensity);b.evaluator.setVariable(b.userIxStr,0);b.evaluator.setVariable(b.userIyStr,0);b.evaluator.setVariable(b.userIzStr,0);O=new a.Primitive3D({vertices:[new a.Vector4D(0,
0,0,1)],type:"vertex"},b);b.evaluator.setFunction(b.id+"._X3D2D_",function(a,c,d){O.vertices[0].x=a;O.vertices[0].y=c;O.vertices[0].z=d;O.computeDepth(b);return O.projVert[0].x});b.evaluator.setFunction(b.id+"._Y3D2D_",function(a,c,d){O.vertices[0].x=a;O.vertices[0].y=c;O.vertices[0].z=d;O.computeDepth(b);return O.projVert[0].y});b.resizable&&(b.wModExpr=c.evaluator.parser.parse(b.wModExpr),b.hModExpr=c.evaluator.parser.parse(b.hModExpr));b.ratio=1;b.addEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=
function(a){b=this;b.initSpace();b.canvas&&(b.canvas.width=b.backCanvas.width=b.w,b.canvas.height=b.backCanvas.height=b.h,b.canvas.style.width=b.backCanvas.style.width=b.w+"px",b.canvas.style.height=b.backCanvas.style.height=b.h+"px");b.w_2=b.w/2;b.h_2=b.h/2;b.w_plus_h=b.w+b.h;b.oldMouse={x:0,y:0};b.S={x:b.h/1080*-20.6*(40/b.scale),y:0,z:0};b.Ojo={x:3*b.w_2,y:0,z:0};b.evaluator.setVariable(b.ojoXStr,b.Ojo.x);b.evaluator.setVariable(b.ojoYStr,b.Ojo.y);b.evaluator.setVariable(b.ojoZStr,b.Ojo.z)};a.Space3D.prototype.update=
function(a){b=this;r=b.evaluator;g=b.parent;r.setVariable(b.wStr,b.w);r.setVariable(b.hStr,b.h);b.drawIfValue=0<r.eval(b.drawif);if(b.drawIfValue){b.resizable&&(wModExpr=b.evaluator.eval(b.wModExpr),hModExpr=b.evaluator.eval(b.hModExpr),b.old_w!=wModExpr||b.old_h!=hModExpr)&&(b.w=wModExpr,b.h=hModExpr,b.w_2=b.w/2,b.h_2=b.h/2,r.setVariable(b.wStr,b.w),r.setVariable(b.hStr,b.h),b.old_w=b.w,b.old_h=b.h,b.canvas.width=b.backCanvas.width=b.w*b.ratio,b.canvas.height=b.backCanvas.height=b.h*b.ratio,b.canvas.style.width=
b.backCanvas.style.width=b.w+"px",b.canvas.style.height=b.backCanvas.style.height=b.h+"px",a=!0,b.S={x:b.h/1080*-20.6*(40/b.scale),y:0,z:0},b.Ojo={x:3*b.w_2,y:0,z:0},b.evaluator.setVariable(b.ojoXStr,b.Ojo.x),b.evaluator.setVariable(b.ojoYStr,b.Ojo.y),b.evaluator.setVariable(b.ojoZStr,b.Ojo.z));q=b.x!==r.eval(b.xExpr)+b.displaceRegionWest;u=b.y!==r.eval(b.yExpr)+g.plecaHeight+b.displaceRegionNorth;b.spaceChange=a||q||u||b.drawBefore!==b.drawIfValue||b.Ox!==r.getVariable(b.OxStr)||b.Oy!==r.getVariable(b.OyStr)||
b.Ojo.x!==r.getVariable(b.ojoXStr)||b.Ojo.y!==r.getVariable(b.ojoYStr)||b.Ojo.z!==r.getVariable(b.ojoZStr)||b.scale!==r.getVariable(b.scaleStr);b.x=q?r.eval(b.xExpr)+b.displaceRegionWest:b.x;b.y=u?r.eval(b.yExpr)+g.plecaHeight+b.displaceRegionNorth:b.y;b.Ojo.x=r.getVariable(b.ojoXStr);b.Ojo.y=r.getVariable(b.ojoYStr);b.Ojo.z=r.getVariable(b.ojoZStr);b.Ox=r.getVariable(b.OxStr);b.Oy=r.getVariable(b.OyStr);b.scale=r.getVariable(b.scaleStr);b.drawBefore=b.drawIfValue;if(a||void 0==b.observer){a=0;for(var c=
b.parent.controls.length;a<c;a++)b.parent.controls[a].id===b.obsStr&&(P=!0);b.observer=P?r.getVariable(b.obsStr)||2.5*b.w_plus_h:2.5*b.w_plus_h;b.observer=m(b.observer,.25*b.w_plus_h);r.setVariable(b.obsStr,b.observer)}1E-6>b.scale?(b.scale=1E-6,r.setVariable(b.scaleStr,1E-6)):1E6<b.scale&&(b.scale=1E6,r.setVariable(b.scaleStr,1E6));if(q||u)b.container.style.left=b.x+"px",b.container.style.top=b.y+"px";b.container.style.display="block";b.dim=r.getVariable(b.userIDimStr);b.userIntensity=r.getVariable(b.userIIStr);
b.light3={x:parseInt(r.getVariable(b.userIxStr)),y:parseInt(r.getVariable(b.userIyStr)),z:parseInt(r.getVariable(b.userIzStr))};b.updateCamera();b.draw()}else b.container.style.display="none"};a.Space3D.prototype.updateCamera=function(){this.eye=a.scalarProduct3D(this.Ojo,1/this.scale)};a.Space3D.prototype.rotateVertex=function(e){v=a.degToRad(b.evaluator.getVariable(b.rotZStr));y=d(v);A=c(v);h=e.x*y-e.y*A;k=e.x*A+e.y*y;f=e.z;v=a.degToRad(b.evaluator.getVariable(b.rotYStr));y=d(v);A=c(v);return{x:f*
A+h*y,y:k,z:f*y-h*A}};a.Space3D.prototype.project=function(a){b=this;this.evaluator.getVariable("URL.oldProj");var c=b.eye.x/(a.x-b.eye.x);return{x:b.getAbsoluteX(c*(b.eye.y-a.y)),y:b.getAbsoluteY(c*(b.eye.z-a.z)),z:b.eye.x-a.x}};a.Space3D.prototype.computeColor=function(b,c,d){b.match("rgba")?b=a.RGBAToHexColor(b):b.match("#")&&(b=new a.Color(b.substring(1)));N=a.subtract3D(this.eye,c.average);M=a.norm3D(N);B=a.scalarProduct3D(N,1/M);this.lights[3]=a.subtract3D(this.light3,c.average);K=a.norm3D(this.lights[3]);
for(var g=0,f=this.intensity.length-1;g<f;g++)E[g]=this.intensity[g]*this.dim;E[3]=this.userIntensity*this.userIntensity/K||0;z=d?this.dim/2:this.dim/4;F=0;L=0>c.direction?c.normal:a.scalarProduct3D(c.normal,-1);g=0;for(f=this.lights.length;g<f;g++)d?(F=Math.max(0,a.dotProduct3D(n(this.lights[g],L),B)),F*=F*F):F=Math.max(0,a.dotProduct3D(this.lights[g],L)),z+=E[g]*F;z=Math.min(z,1);C=e(b.r*z);I=e(b.g*z);G=e(b.b*z);return"rgba("+C+","+I+","+G+","+b.a+")"};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,
0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);this.image&&""!=this.image.src&&this.image.ready&&this.image.complete&&("topleft"===this.bg_display?this.ctx.drawImage(this.image,0,0):"stretch"===this.bg_display?this.ctx.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):
"center"===this.bg_display&&this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));if(!this.click){for(var a=0,b=this.graphics.length;a<b;a++)this.graphics[a].update();this.primitives=[];if(this.split)for(a=0,b=this.graphics.length;a<b;a++){l=this.graphics[a];for(var c=a+1;c<b;c++)w=this.graphics[c],l.splitFace(w),w.splitFace(l);this.primitives=this.primitives.concat(l.primitives||[])}else for(a=0,b=this.graphics.length;a<b;a++){l=this.graphics[a];if(l.split)for(c=
a+1;c<b;c++)w=this.graphics[c],w.split&&l.splitFace(w);this.primitives=this.primitives.concat(l.primitives||[])}}a=0;for(b=this.primitives.length;a<b;a++)this.primitives[a].computeDepth(this);this.primitives=this.primitives.sort(function(a,b){return b.depth-a.depth});if("painter"===this.render)this.drawPainter(this.primitives);else for(a=0,b=this.primitives.length;a<b;a++)this.primitives[a].draw(this.ctx,this);a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.drawPainter=
function(a){for(var b=a.length,c=0;c<b;c++)a[c].drawn=!1,a[c].draw(this.ctx,this);for(var d=[],e=[],g=0,f=a.length,h=.001,k,l;;){k=f;for(c=0;c<b;c++)if(!a[c].drawn){l=!0;for(var m=0;m<b;m++)if(m!=c&&!a[m].drawn&&a[c].inFrontOf(d,a[m],h)){l=!1;break}l&&(f--,e[g++]=a[c],a[c].drawn=!0)}if(0==f)break;else if(f==k){if(h*=10,.1<h){for(c=0;c<b;c++)a[c].drawn||(e[g++]=a[c],a[c].drawn=!0);break}}else h=.001}for(c=0;c<b;c++)e[c].draw(this.ctx,this)};a.Space3D.prototype.rayFromEye=function(a,b){return{x:-this.eye.x,
y:(a-(this.w_2+this.Ox))/this.scale-this.eye.y,z:(this.h_2+this.Oy-b)/this.scale-this.eye.z}};a.Space3D.prototype.addEvents=function(){function b(a){window.focus();document.activeElement.blur();f.click=0;f.evaluator.setVariable(f.id+".mouse_pressed",0);window.removeEventListener("touchmove",g,!1);window.removeEventListener("touchend",b,!1);a.preventDefault();f.parent.update()}function c(b){document.body.focus();f.click=0;f.evaluator.setVariable(f.id+".mouse_pressed",0);b.preventDefault();"R"===f.whichBtn&&
(window.removeEventListener("mousemove",e,!1),f.posZoom==f.posZoomNew&&a.showConfig&&f.parent.externalSpace.show());window.removeEventListener("mousemove",g,!1);window.removeEventListener("mouseup",c,!1);f.parent.update()}function d(b){f.posAnte=a.getCursorPosition(b,f.container);f.mouse_x=f.getRelativeX(f.posAnte.x);f.mouse_y=f.getRelativeY(f.posAnte.y);f.evaluator.setVariable(f.id+".mouse_x",f.mouse_x);f.evaluator.setVariable(f.id+".mouse_y",f.mouse_y);f.parent.update();Date.now()}function e(b){b.preventDefault();
f.posZoomNew=a.getCursorPosition(b,f.container).y;f.evaluator.setVariable(f.scaleStr,f.tempScale+f.tempScale/45*((f.posZoom-f.posZoomNew)/10));f.posObserverNew=a.getCursorPosition(b,f.container).x;f.evaluator.setVariable(f.obsStr,f.tempObserver-2.5*(f.posObserver-f.posObserverNew));f.parent.update()}function g(b){if(!f.fixed&&f.click){x=(f.getAbsoluteX(f.oldMouse.x)-f.getAbsoluteX(f.mouse_x))/4;p=(-f.getAbsoluteY(f.oldMouse.y)+f.getAbsoluteY(f.mouse_y))/4;if(x!==f.disp.x||p!==f.disp.y)f.alpha=a.degToRad(f.evaluator.getVariable(f.rotZStr)),
f.beta=a.degToRad(-f.evaluator.getVariable(f.rotYStr)),f.alpha=a.radToDeg(f.alpha)-x,f.beta=a.radToDeg(f.beta)-p,f.evaluator.setVariable(f.rotZStr,f.alpha),f.evaluator.setVariable(f.rotYStr,-f.beta),f.disp.x=x,f.disp.y=p,f.oldMouse.x=f.getRelativeX(f.posAnte.x),f.oldMouse.y=f.getRelativeY(f.posAnte.y);d(b);b.preventDefault()}}var f=this;this.canvas.oncontextmenu=function(){return!1};this.canvas.addEventListener("touchstart",function(c){window.focus();document.activeElement.blur();f.click=1;f.evaluator.setVariable(f.id+
".mouse_pressed",1);f.parent.deactivateGraphiControls();f.posAnte=a.getCursorPosition(c,f.container);f.oldMouse.x=f.getRelativeX(f.posAnte.x);f.oldMouse.y=f.getRelativeY(f.posAnte.y);d(c);window.addEventListener("touchmove",g);window.addEventListener("touchend",b);c.preventDefault()});this.canvas.addEventListener("mousedown",function(b){document.body.focus();f.click=1;f.parent.deactivateGraphiControls();f.whichBtn=a.whichBtn(b);"R"===f.whichBtn?(window.addEventListener("mouseup",c),f.posObserver=
a.getCursorPosition(b,f.container).x,f.posObserverNew=f.posObserver,f.posZoom=a.getCursorPosition(b,f.container).y,f.posZoomNew=f.posZoom,f.fixed||(f.tempScale=f.scale,f.tempObserver=f.observer,window.addEventListener("mousemove",e))):"L"==f.whichBtn&&(f.evaluator.setVariable(f.id+".mouse_pressed",1),f.posAnte=a.getCursorPosition(b,f.container),f.oldMouse.x=f.getRelativeX(f.posAnte.x),f.oldMouse.y=f.getRelativeY(f.posAnte.y),d(b),window.addEventListener("mousemove",g),window.addEventListener("mouseup",
c));b.preventDefault()});this.disp={x:0,y:0};this.canvas.addEventListener("dblclick",function(a){})};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h,k,f,n,e,m;a.SpaceHTML_IFrame=function(d,c){a.Space.call(this,d,c);h=this.parent.evaluator;void 0!=this._w_&&(d=h.parser.parse(this._w_),this._w_="number"!=d.type?d:void 0);void 0!=this._h_&&(d=h.parser.parse(this._h_),this._h_="number"!=d.type?d:void 0);this.isFirefox=/firefox/i.test(window.navigator.userAgent);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=h.parser.parse(this.file.substring(1,this.file.length-
1)):this.file.match(/^'/)&&this.file.match(/'$/)?this.file=h.parser.parse(this.file):this.file=h.parser.parse("'"+this.file+"'");this.oldFile=h.eval(this.file);this.MyIFrame=document.createElement("iframe");0!=this.oldFile&&this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");this.MyIFrame.setAttribute("style","position:static;left:0;top:0;");
this.container=document.createElement("div");this.container.setAttribute("id",this.id);this.container.setAttribute("style",(a.isIOS?"overflow:scroll;-webkit-overflow-scrolling:touch;overflow-scrolling:touch;":"")+"position:absolute;width:"+this.w+"px;height:"+this.h+"px;left:"+this.x+"px;top:"+this.y+"px;z-index:"+this.zIndex+";background-repeat:no-repeat;background-position:center;");this.container.appendChild(this.MyIFrame);this.imageSrc&&(this.container.style.backgroundImage="url("+this.imageSrc+
")");this.parent.container.insertBefore(this.container,this.parent.loader);var e=this;this.MyIFrame.onload=function(c){var b=this;e.evaluator.setFunction(e.id+".set",function(a,c){b.contentWindow.postMessage({type:"set",name:a,value:c},"*");return 0});e.evaluator.setFunction(e.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*");return 0});e.evaluator.setFunction(e.id+".exec",function(a,c){b.contentWindow.postMessage({type:"exec",name:a,value:c},"*");return 0});e.evaluator.setFunction(e.id+
".changeConf",function(c){if(c){if(a.cacheFiles[c])var d=a.cacheFiles[c];else d=(d=document.getElementById(c))&&"descartes/embed"===d.type?d.textContent:a.openExternalFile(c),d=(d=(new DOMParser).parseFromString(d,"text/html").querySelector("ajs"))?d.innerHTML:"",a.cacheFiles[c]=d;b.contentWindow.postMessage({type:"change_config",filename:c,content:d},"*")}return 0});e.ImReady=!e.isFirefox;e.isFirefox||(e.container.style.visibility="visible",e.container.style.opacity="1",e.container.style.zIndex=
e.zIndex,e.container.style.display=e.drawIfValue?"block":"none");e.MyIFrame.style.visibility="visible";e.container.style.backgroundImage=""};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){e=this;e.initSpace();e.MyIFrame&&(e.MyIFrame.style.width=e.w+"px",e.MyIFrame.style.height=e.h+"px",e.MyIFrame.style.left=e.x+"px",e.MyIFrame.style.top=e.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=
function(a){h=this.evaluator;this.drawIfValue=0<h.eval(this.drawif);this.ImReady?this.container.style.display=this.drawIfValue?"block":"none":(this.container.style.visibility=this.drawIfValue?"visible":"hidden",this.container.style.opacity=this.drawIfValue?"1":"0",this.container.style.zIndex=this.drawIfValue?this.zIndex:-1E3);if(this.drawIfValue){this.MyIFrame.contentWindow.focus();a&&(this.y=this.x=Infinity);k=this.x!==h.eval(this.xExpr)+this.displaceRegionWest;f=this.y!==h.eval(this.yExpr)+this.parent.plecaHeight+
this.displaceRegionNorth;this.x=k?h.eval(this.xExpr)+this.displaceRegionWest:this.x;this.y=f?h.eval(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;void 0!=this._w_&&(a=h.eval(this._w_),this.w!==a&&(this.container.style.width=this.MyIFrame.style.width=a+"px",this.w=a));void 0!=this._h_&&(a=h.eval(this._h_),this.h!==a&&(this.container.style.height=this.MyIFrame.style.height=a+"px",this.h=a));if(k||f)this.container.style.left=this.x+"px",this.container.style.top=this.y+"px";n=h.eval(this.file);
n!==this.oldFile&&(this.ImReady=!1,this.isFirefox||(this.container.style.display="block",this.container.style.visibility=this.drawIfValue?"visible":"hidden",this.container.style.opacity=this.drawIfValue?"1":"0",this.container.style.zIndex=this.drawIfValue?this.zIndex:-1E3),this.imageSrc&&(this.container.style.backgroundImage="url("+this.imageSrc+")"),this.MyIFrame.style.visibility="hidden",this.oldFile=n,this.MyIFrame.contentWindow.location.replace(n));m=h.getVariable(this.id+"._scroll");1==m?(this.MyIFrame.setAttribute("scrolling",
"yes"),this.MyIFrame.style.overflow=""):-1==m?(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}else this.MyIFrame.contentWindow.blur()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;var h=1;a.DescartesLoader=function(k){this.children=k.children;this.lessonParser=k.lessonParser;this.images=k.images;this.images.length=k.images.length;this.audios=k.audios;this.audios.length=k.audios.length;this.descartesApp=k;this.imgLoader=document.createElement("div");this.imgLoader.setAttribute("class","DescartesLoaderImage");this.progress=document.createElement("progress");this.progress.setAttribute("class","PBL");this.progress.setAttribute("value",
0);this.progress.setAttribute("max",100);k.imgLoader?this.imgLoader.setAttribute("style","background-image:url("+k.imgLoader+");background-size:contain;"):(h=k.width<k.height?k.width/1144:k.height/1092,h=2.5<h?2.5:h,this.imgLoader.setAttribute("style","background-image:url("+a.loaderImg.src+");background-position:50% 33.5%;background-size:"+880*h+"px;"),this.progress.setAttribute("style","visibility:visible; left:"+(k.width-726*h)/2+"px; top:"+(33.5*k.height/100+940*h/2)+"px; width:"+726*h+"px; height:"+
14*h+"px;"));k.loader.appendChild(this.imgLoader);k.loader.appendChild(this.progress);k.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var h=this,f=h.children,n=h.images,e=h.audios,m=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,d=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;n["lib/DescartesCCLicense.png"]=a.getCCLImg();n["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1});n["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=
1});var c,r;var g=0;for(c=f.length;g<c;g++)if("rtf"!==f[g].name){if(f[g].value.match(/'macro'|'makro'/g)){var b="";var l=h.lessonParser.split(f[g].value);var w=0;for(r=l.length;w<r;w++)"expresion"===babel[l[w][0]]&&(b=l[w][1]);if(b)var q=(q=document.getElementById(b))&&"descartes/macro"==q.type?q.text:a.openExternalFile(b);if(q&&(l=q.match(m)))for(b=0,r=l.length;b<r;b++)w=l[b],w.toLowerCase().match(/vacio.gif$/)||""==w.substring(0,w.length-4)||(n[w]=new Image,n[w].addEventListener("load",function(){this.ready=
1}),n[w].addEventListener("error",function(){this.errorload=1}),n[w].src=w)}if(l=f[g].value.match(m))for(b=0,r=l.length;b<r;b++)w=l[b],w.toLowerCase().match(/vacio.gif$/)||""==w.substring(0,w.length-4)||(n[w]=new Image,n[w].addEventListener("load",function(){this.ready=1}),n[w].addEventListener("error",function(){this.errorload=1}),n[w].src=w);if(l=f[g].value.match(d))for(b=0,w=l.length;b<w;b++)h.initAudio(l[b])}for(var u in n)n.hasOwnProperty(u)&&h.images.length++;for(u in e)e.hasOwnProperty(u)&&
h.audios.length++;var x=h.images.length+h.audios.length;0<x&&h.progress.setAttribute("max",x);var p,v=function(){p=0;for(var b in n)n.hasOwnProperty(b)&&(n[b].ready||n[b].errorload)&&p++;for(b in e)e.hasOwnProperty(b)&&(e[b].ready||e[b].errorload)&&p++;h.progress.setAttribute("value",p);p!=x?h.timer=a.setTimeout(v,1):h.descartesApp.initBuildApp()};v()};a.DescartesLoader.prototype.initAudio=function(h){var f=this.audios;f[h]=new Audio(h);f[h].filename=h;var k=function(){this.ready=1},e=function(){this.canPlayType("audio/"+
this.filename.substring(this.filename.length-3))||"mp3"!=this.filename.substring(this.filename.length-3)?(console.log("El archivo '"+h+"' no puede ser reproducido"),this.errorload=1):(f[h]=new Audio(this.filename.replace("mp3","ogg")),f[h].filename=this.filename.replace("mp3","ogg"),f[h].addEventListener("canplaythrough",k),f[h].addEventListener("load",k),f[h].addEventListener("error",e),f[h].load())};f[h].addEventListener("canplaythrough",k);f[h].addEventListener("load",k);f[h].addEventListener("error",
e);a.hasTouchSupport?(f[h].load(),f[h].play(),a.setTimeout(function(){f[h].pause()},20),f[h].ready=1):f[h].load()};return a}(descartesJS||{});
descartesJS=function(a){function h(a){for(var c="[",d=0,e=a.length;d<e;d++)Array.isArray(a[d])?c+=h(a[d]):(f=a[d]||0,"string"==typeof f&&(f="'"+f+"'"),c+=f),d<e-1&&(c+=",");return c+"]"}function k(){n=window.innerWidth/this.width;e=window.innerHeight/this.height;m=Math.min(n,e);a.cssScale=m;this.container.parentNode.setAttribute("align","");this.container.style.transformOrigin="0 0";n<e?(this.container.style.left="0",this.container.style.transform="translate3d(0px, 0px, 0px) scale("+m+")"):(this.container.style.left=
"50%",this.container.style.transform="translate3d(0px, 0px, 0px) scale("+m+") translate(-50%, 0)")}if(a.loadLib)return a;var f,n,e,m;a.DescartesApp=function(d){this.animation={playing:!1,play:function(){},stop:function(){},reinit:function(){}};this.ratio=a._ratio;this.applet=d;this.parentC=d.parentNode;this.width=parseFloat(d.getAttribute("width"));this.height=parseFloat(d.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=/\./g;this.language="espa\u00f1ol";this.children=d.getElementsByTagName("param");
a.ccLicense=!0;for(var c=0,e=this.children.length;c<e;c++)"CreativeCommonsLicense"===this.children[c].name&&(a.ccLicense="no"!==this.children[c].value);this.code=d.getAttribute("code");this.saveState=[];this.images={length:-1};this.audios={length:-1};this.firstRun=!0;this.scaleToFit=function(){};this.evaluator=new a.Evaluator(this);this.getURLParameters();this.lessonParser=new a.LessonParser(this);this.init()};a.DescartesApp.prototype.init=function(){this.stop();this.arquimedes=/DescartesWeb2_0|Arquimedes|Discurso/i.test(this.code);
this.licenseA=a.ccLicense?"{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________\\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/4.0/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Descartes, que es un producto de c\u00f3digo abierto, {\\*\\hyperlink Creditos|http://arquimedes.matem.unam.mx/Descartes5/creditos/conCCL.html}\\par }":
"";for(var d=this.children,c,e=0,f=0,b=a.ccLicense?90:0,h=0,m=d.length;h<m;h++)c=d[h],"rtf_height"==c.name&&(e=parseInt(c.value)||this.height),"Buttons"==babel[c.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(c.value),f=this.buttonsConfig.height),"image_loader"==c.name&&(this.imgLoader=c.value),"expand"==c.name&&("cover"==c.value?this.expand=c.value:"fit"==c.value&&(this.scaleToFit=k)),"docBase"==c.name&&(this.docBase=c.value,c=document.createElement("base"),c.setAttribute("id","descartesJS_base"),
c.setAttribute("href",this.docBase),document.head.appendChild(c));"cover"===this.expand&&(this.width=window.innerWidth,this.height=window.innerHeight);this.arquimedes&&(this.ratio=1,e&&(this.height=e+f+b));this.spaces=[];this.externalSpace&&document.body.removeChild(this.externalSpace.container);this.externalSpace=new a.SpaceExternal(this);this.northSpace={container:document.createElement("div"),controls:[]};this.southSpace={container:document.createElement("div"),controls:[]};this.eastSpace={container:document.createElement("div"),
controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};this.controls=[];this.auxiliaries=[];this.events=[];this.nIframes=this.plecaHeight=this.tabindex=this.zIndex=0;void 0!=this.container&&this.parentC.removeChild(this.container);this.container=document.createElement("div");this.loader=document.createElement("div");this.parentC.insertBefore(this.container,this.parentC.firstChild);this.container.width=
this.width;this.container.height=this.height;this.container.setAttribute("class","DescartesAppContainer");this.container.setAttribute("style","width:"+this.width+"px;height:"+this.height+"px;");this.scaleToFit();this.container.appendChild(this.loader);this.loader.width=this.width;this.loader.height=this.height;this.loader.setAttribute("class","DescartesLoader");this.loader.setAttribute("style","width:"+this.width+"px;height:"+this.height+"px;z-index:1000;display:none;");this.imgLoader&&(this.loader.style.backgroundColor=
"rgba(0,0,0,0)");this.firstRun?(this.loader.style.display="block",this.descartesLoader=new a.DescartesLoader(this)):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){a.showConfig=!0;for(var d=this.children,c,e=this.lessonParser,f=[],b=[],h=[],k=[],m=[],n=[],x=0,p=d.length;x<p;x++)if(c=d[x],"editable"==babel[c.name])a.showConfig="false"==babel[c.value]?!1:!0;else if("language"==babel[c.name])this.language=c.value;else if("pleca"==c.name)c=e.parsePleca(c.value,this.width),this.container.insertBefore(c,
this.loader),this.plecaHeight=c.imageHeight?c.imageHeight:c.offsetHeight;else if("Buttons"==babel[c.name])this.buttonsConfig=e.parseButtonsConfig(c.value);else if("decimal_symbol"==babel[c.name])this.decimal_symbol=c.value,this.decimal_symbol_regexp=new RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[c.name])this.version=parseInt(c.value);else if("language"==babel[c.name])this.language=c.value;else if("rtf"==c.name){var v=(this.width-780)/2,y=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-
45;k.push("space='descartesJS_stage' type='text' expresion='[10,20]' background='yes' text='"+c.value.replace(/'/g,"&squot;")+"'");k.push("space='descartesJS_stage' type='text' expresion='["+v+","+(y-25)+"]' background='yes' text='"+this.licenseA+"'");a.ccLicense&&k.push("space='descartesJS_stage' type='image' expresion='["+(v+15)+","+y+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==c.name.charAt(0)?(c.value.match(/'HTMLIFrame'/)&&this.nIframes++,f.push(c.value)):
/^C_/.test(c.name)?b.push(c.value):/^A_/.test(c.name)?h.push(c.value):/^G_/.test(c.name)?(c.value.match(/type='fill'|tipo='relleno'|tipus='ple'|mota='betea'|type='plein'|tipo='recheo'|tipo='curva_piena'|tipo='preencher'|tipus='ple'/)&&(this.ratio=1),k.push(c.value)):/^S_/.test(c.name)?m.push(c.value):"Animation"==babel[c.name]&&n.push(c.value);this.arquimedes&&(this.stage={container:document.createElement("div"),scroll:0},this.stage.container.setAttribute("id","descartesJS_Stage"),this.stage.stageSpace=
this.lessonParser.parseSpace("tipo='R2' id='descartesJS_stage' fondo='"+(a.TextController?"ffffffff":"blanco")+"' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+this.width+"' alto='"+this.height+"'"),this.stage.container.appendChild(this.stage.stageSpace.container),this.container.appendChild(this.stage.container),this.spaces.push(this.stage.stageSpace));x=0;for(p=f.length;x<p;x++)d=e.parseSpace(f[x]),this.arquimedes&&this.stage.container.appendChild(d.container),this.spaces.push(d),
this.zIndex++;x=0;for(p=k.length;x<p;x++)if(a.DEBUG.elemIndex=x,f=e.parseGraphic(k[x]))this.editableRegionVisible=this.editableRegionVisible||f.visible,f.space.addGraph(f);x=0;for(p=m.length;x<p;x++)(f=e.parse3DGraphic(m[x]))&&f.space.addGraph(f,!0);x=0;for(p=b.length;x<p;x++)this.controls.push(e.parseControl(b[x]));x=0;for(p=h.length;x<p;x++)e.parseAuxiliar(h[x]);x=0;for(p=n.length;x<p;x++)this.animation=e.parseAnimation(n[x]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();
x=0;for(p=this.controls.length;x<p;x++)this.controls[x].init();this.updateControls();this.updateSpaces(!0);var A=this;this.nIframes?a.setTimeout(function(){A.finishInit()},200*this.nIframes):this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.evaluator.setVariable("decimalSymbol",this.decimal_symbol);this.update();this.loader.style.display="none";window.parent!==window&&(this.parentC.style.margin=this.parentC.style.padding=0,window.parent.postMessage({type:"reportSize",href:window.location.href,
width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready",value:window.location.href},"*"),a.onResize());window.opener&&window.opener.postMessage({type:"isResizeNeeded",href:window.location.href},"*");this.externalSpace.init();try{var d=new CustomEvent("descartesReady",{detail:this})}catch(c){console.warn("CustomEvents not supported in this browser")}window.dispatchEvent(d);this.readyApp=!0};a.DescartesApp.prototype.adjustSize=function(){document.body.style.margin=document.body.style.padding=
this.parentC.style.margin=this.parentC.style.padding="0";var d=parseInt(this.width)+30,c=parseInt(this.height)+90;window.moveTo((parseInt(screen.width)-d)/2,(parseInt(screen.height)-c)/2);window.resizeTo(d,c);a.onResize()};a.DescartesApp.prototype.adjustDimensions=function(){if(void 0==this.init_w||void 0==this.init_h)this.init_w=parseInt(this.container.style.width),this.init_h=parseInt(this.container.style.height);var a=parseInt(this.parentC.offsetWidth);var c=this.init_w;var e=a/c;c>a?(this.parentC!=
document.body&&(this.parentC.style.height=this.init_h*e+"px"),this.percent=e,this.container.style.webkitTransform=this.container.style.MozTransform="scale("+e+")",this.container.style.webkitTransformOrigin=this.container.style.MozTransformOrigin="top left"):(this.parentC!=document.body&&(this.parentC.style.height="auto"),this.percent=1,this.container.style.webkitTransform=this.container.style.MozTransform="",this.container.style.webkitTransformOrigin=this.container.style.MozTransformOrigin="")};a.DescartesApp.prototype.configRegions=
function(){var d=this.evaluator.parser,c=this.buttonsConfig,e=this.container,f="15",b=configWidth=initWidth=clearWidth=100;2==this.version&&(f="14",b=63,configWidth=50,initWidth=44,clearWidth=53);var h=southRegionHeight=eastRegionHeight=westRegionHeight=editableRegionHeight=northRegionWidht=southRegionWidht=eastRegionWidth=westRegionWidth=0,k=this.northSpace.controls,m=this.southSpace.controls,n=this.eastSpace.controls,x=this.westSpace.controls;if(0<c.rowsNorth||0<k.length||c.about||c.config){0>=
c.rowsNorth?(h=c.height,c.rowsNorth=1):h=c.height*c.rowsNorth;var p=this.northSpace.container;p.setAttribute("id","descartesJS_north");p.setAttribute("style","width:"+e.width+"px;height:"+h+"px;background:#c0c0c0;position:absolute;left:0;top:"+this.plecaHeight+"px;z-index:100;");e.insertBefore(p,this.loader);northRegionWidht=e.width;var v=0;c.about?(v=b,northRegionWidht-=v):b=0;c.config&&(northRegionWidht-=configWidth);p=Math.ceil(k.length/c.rowsNorth);for(var y=northRegionWidht/p,A=0,C=k.length;A<
C;A++)k[A].expresion=d.parse("("+(v+A%p*y)+","+c.height*Math.floor(A/p)+","+y+","+c.height+")"),k[A].drawif=d.parse("1"),k[A].init();c.about&&(A=new a.Button(this,{region:"north",name:"english"==this.language?"about":"cr\u00e9ditos",font_size:d.parse(f),expresion:d.parse("(0, 0, "+b+", "+h+")")}),A.actionExec={execute:a.showAbout},A.update());c.config&&(new a.Button(this,{region:"north",name:"config",font_size:d.parse(f),action:"config",expresion:d.parse("("+(northRegionWidht+b)+", 0, "+configWidth+
", "+h+")")})).update()}if(0<c.rowsSouth||0<m.length||c.init||c.clear){0>=c.rowsSouth?(southRegionHeight=c.height,c.rowsSouth=1):southRegionHeight=c.height*c.rowsSouth;southRegionWidht=e.width;v=0;c.init?(v=initWidth,southRegionWidht-=v):initWidth=0;c.clear&&(southRegionWidht-=clearWidth);p=this.southSpace.container;p.setAttribute("id","descartesJS_south");p.setAttribute("style","width:"+e.width+"px;height:"+southRegionHeight+"px;background:#c0c0c0;position:absolute;left:0;top:"+(e.height-southRegionHeight)+
"px;z-index:100;");e.insertBefore(p,this.loader);p=Math.ceil(m.length/c.rowsSouth);y=southRegionWidht/p;A=0;for(C=m.length;A<C;A++)m[A].expresion=d.parse("("+(v+A%p*y)+","+c.height*Math.floor(A/p)+","+y+","+c.height+")"),m[A].drawif=d.parse("1"),m[A].init();c.init&&(new a.Button(this,{region:"south",name:"english"==this.language?"init":"inicio",font_size:d.parse(f),action:"init",expresion:d.parse("(0, 0, "+initWidth+", "+southRegionHeight+")")})).update();c.clear&&(new a.Button(this,{region:"south",
name:"english"==this.language?"clear":"limpiar",font_size:d.parse(f),action:"clear",expresion:d.parse("("+(southRegionWidht+initWidth)+", 0, "+clearWidth+", "+southRegionHeight+")")})).update()}if(0<n.length)for(eastRegionHeight=e.height-h-southRegionHeight,eastRegionWidth=c.widthEast,p=this.eastSpace.container,p.setAttribute("id","descartesJS_east"),p.setAttribute("style","width:"+eastRegionWidth+"px;height:"+eastRegionHeight+"px;background:#c0c0c0;position:absolute;left:"+(e.width-eastRegionWidth)+
"px;top:"+h+"px;z-index:100;"),e.insertBefore(p,this.loader),A=0,C=n.length;A<C;A++)n[A].expresion=d.parse("(0,"+c.height*A+","+eastRegionWidth+","+c.height+")"),n[A].drawif=d.parse("1"),n[A].init();if(0<x.length)for(westRegionHeight=e.height-h-southRegionHeight,westRegionWidth=c.widthWest,p=this.westSpace.container,p.setAttribute("id","descartesJS_west"),p.setAttribute("style","width: "+westRegionWidth+"px;height:"+westRegionHeight+"px;background:#c0c0c0;position:absolute;left:0;top:"+h+"px;z-index:100;"),
e.insertBefore(p,this.loader),A=0,C=x.length;A<C;A++)x[A].expresion=d.parse("(0,"+c.height*A+","+westRegionWidth+","+c.height+")"),x[A].drawif=d.parse("1"),x[A].init();if(this.editableRegionVisible)for(editableRegionHeight=c.height,p=this.editableRegion.container,p.setAttribute("id","descartesJS_editableRegion"),p.setAttribute("style","width:"+e.width+"px;height:"+editableRegionHeight+"px;position:absolute;left:0;top:"+(e.height-southRegionHeight-c.height)+"px;z-index:100;background:#c0c0c0;overflow:hidden;"),
e.insertBefore(p,this.loader),d=this.editableRegion.textFields,e=e.width/d.length,c=a.getFieldFontSize(editableRegionHeight),A=0,C=d.length;A<C;A++)"div"==d[A].type?(p.appendChild(d[A].container),d[A].container.setAttribute("style","font-family:"+a.sansserif_font+";width:"+(e-4)+"px;height:"+editableRegionHeight+"px;position:absolute;left:"+A*e+"px;top:0;"),f=d[A].container.firstChild,f.setAttribute("style","font-family:"+a.sansserif_font+";font-size:"+c+"px;padding-top:0;background-color:#e0e4e8;position:absolute;left:0;top:0;height:"+
editableRegionHeight+"px;text-align:center;line-height:"+editableRegionHeight+"px;"),b=f.offsetWidth,f.style.width=b+"px",f.firstChild.textContent=f.firstChild.textContent.substring(3,f.firstChild.textContent.length-3),d[A].container.lastChild.setAttribute("style","font-family:"+a.monospace_font+";font-size:"+c+"px;width:"+(e-b)+"px;height:"+editableRegionHeight+"px;position:absolute;left:"+b+"px;top:0;border:2px groove white;")):(p.appendChild(d[A]),d[A].setAttribute("style","font-family:"+a.monospace_font+
";font-size:"+c+"px;width:"+e+"px;height:"+editableRegionHeight+"px;position:absolute;left:"+A*e+"px;top:0;border:2px groove white;"));this.displaceRegionNorth=h;this.displaceRegionSouth=southRegionHeight;this.displaceRegionEast=eastRegionWidth;this.displaceRegionWest=westRegionWidth;A=0;for(C=this.spaces.length;A<C;A++)this.spaces[A].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateControls();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.clearClick=
function(){for(var a=0,c=this.spaces.length;a<c;a++)this.spaces[a].clearClick()};a.DescartesApp.prototype.removeButtonClick=function(){a.newBlobContent=null;for(var d=0,c=this.controls.length;d<c;d++)this.controls[d].buttonClick=!1};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,c=0,e=this.controls.length;c<e;c++)a=this.controls[c],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,c=this.auxiliaries.length;a<c;a++)this.auxiliaries[a].update()};
a.DescartesApp.prototype.updateEvents=function(){for(var a=0,c=this.events.length;a<c;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,c=this.controls.length;a<c;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var c=0,d=this.spaces.length;c<d;c++)this.spaces[c].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,c=this.spaces.length;a<c;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&this.spaces[a].drawBackground()};
a.DescartesApp.prototype.play=function(){this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation.reinit()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var c=this.images;return a?(c[a]||(c[a]=new Image,c[a].addEventListener("load",
function(){this.ready=1}),c[a].addEventListener("error",function(){this.ready=0;this.errorload=1}),c[a].src=a),c[a]):new Image};a.DescartesApp.prototype.getAudio=function(d){var c=this.audios;if(d){if(!c[d]){d.lastIndexOf(".");c[d]=new Audio(d);var e=function(a){this.ready=1};c[d].addEventListener("canplaythrough",e);var f=function(a){this.canPlayType("audio/"+d.substring(d.length-3))||"mp3"!=d.substring(d.length-3)?(console.log("El archivo '"+d+"' no puede ser reproducido"),this.errorload=1):(c[d]=
new Audio(d.replace("mp3","ogg")),c[d].addEventListener("canplaythrough",e),c[d].addEventListener("load",e),c[d].addEventListener("error",f),c[d].load())};c[d].addEventListener("error",f);c[d].play();a.setTimeout(function(){c[d].pause()},15)}return c[d]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){return this.getControlById(a,!0)};a.DescartesApp.prototype.getControlById=function(a,c){c=c?"cID":"id";for(var d,e=0,b=this.controls.length;e<b;e++)if(d=this.controls[e],d[c]==
a)return d;return{update:function(){},w:0,h:0}};a.DescartesApp.prototype.getSpaceByCId=function(a){return this.getSpaceById(a,!0)};a.DescartesApp.prototype.getSpaceById=function(a,c){c=c?"cID":"id";for(var d,e=0,b=this.spaces.length;e<b;e++)if(d=this.spaces[e],d[c]==a)return d;return{update:function(){},w:0,h:0}};a.DescartesApp.prototype.getURLParameters=function(){var a=window.location.href,c=a.indexOf("?");if(-1!=c){a=decodeURIComponent(a.substring(c+1)).split("&");for(var e=0,f=a.length;e<f;e++)c=
a[e].split("="),2==c.length&&(+c[1]==+c[1]&&(c[1]=parseFloat(c[1])),this.evaluator.setVariable("URL."+c[0],c[1]))}};a.DescartesApp.prototype.getState=function(){var a="",c=this.evaluator.variables,e;for(e in c)if(c.hasOwnProperty(e)){var f=c[e];"string"==typeof f&&(f="'"+f+"'");void 0!=f&&"rnd"!=e&&"\u03c0"!=e&&"pi"!=e&&"e"!=e&&"Infinity"!=e&&"-Infinity"!=e&&"object"!=typeof f&&(a=""!=a?a+"\n"+e+"="+f:e+"="+f)}f=this.evaluator.vectors;for(var b in f)f.hasOwnProperty(b)&&(a+="\n"+b+"="+h(f[b]));b=
this.evaluator.matrices;for(var k in b)b.hasOwnProperty(k)&&(a+="\n"+k+"="+h(b[k]));return a};a.DescartesApp.prototype.setState=function(a,c){a=a.split("\n");for(var d,e,b=0,f=a.length;b<f;b++)d=a[b].split("="),2<=d.length&&(e=eval(d[1]),-1!=d[1].indexOf("[[")?(this.evaluator.matrices[d[0]]=e,this.evaluator.matrices[d[0]].rows=e.length,this.evaluator.matrices[d[0]].cols=e[0].length):-1!=d[1].indexOf("[")?(this.evaluator.vectors[d[0]]=e,this.evaluator.variables[d[0]+".long"]=e.length):this.evaluator.variables[d[0]]=
e);c||this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=correct=0,c="",e=0,f=this.controls.length;e<f;e++)"textfield"==this.controls[e].gui&&this.controls[e].evaluate&&(a++,correct+=this.controls[e].ok,this.controls[e].value=""==this.controls[e].value?"''":this.controls[e].value,c+=" \\n "+this.controls[e].id+"="+this.controls[e].value+"|"+this.controls[e].ok);return"questions="+a+" \\n correct="+correct+" \\n wrong="+(a-correct)+c};a.DescartesApp.prototype.showSolution=function(){for(var a=
this.controls,c=0,e=a.length;c<e;c++)"textfield"==a[c].gui&&a[c].evaluate&&a[c].changeValue(a[c].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,c=this.saveState.length;a<c;a++)this.evaluator.eval(this.saveState[a]);this.update()};return a}(descartesJS||{});
descartesJS=function(a){if(a.loadLib)return a;a.DEBUG={PARENTHESIS_CLOSING:"Faltan par\u00e9ntesis por cerrar",PARENTHESIS_OPENING:"Faltan par\u00e9ntesis por abrir",BRACKET_CLOSING:"Faltan corchetes por cerrar",BRACKET_OPENING:"Faltan corchetes por abrir",INCOMPLETE_IF:"Condicional incompleta",EXPRESSION:"En la expresi\u00f3n"};a.DEBUG.setError=function(h,k){h="Error: "+h+" en\u300a "+k+" \u300b. ";var f="";switch(a.DEBUG.objectName){case "Auxiliar":k="event"===a.DEBUG.typeName||"algorithm"===a.DEBUG.typeName||
"constant"===a.DEBUG.typeName?"En el programa ":"En la definici\u00f3n ";if("doExpr"==babel[a.DEBUG.paramName]||"init"==babel[a.DEBUG.paramName])f=" en la l\u00ednea "+(a.DEBUG.lineCount+1);h+=k+"\u300c"+a.DEBUG.idName+"\u300d, en el param\u00e9tro \u300c"+a.DEBUG.paramName+"\u300d"+f+".";break;case "Graphic":h+="En el gr\u00e1fico #"+(a.DEBUG.elemIndex+1)+" de tipo \u300c"+a.DEBUG.idName+"\u300d, en el param\u00e9tro \u300c"+a.DEBUG.paramName+"\u300d."}console.info(h)};return a}(descartesJS||{});
descartesJS=function(a){function h(f){f=document.createElement("div");for(var h='<div style="font-size:12px;visibility:hidden;">\n',e="descartesJS_serif descartesJS_sansserif descartesJS_monospace DJS_symbola DJS_extra DJS_sansserif DJS_serif DJS_monospace".split(" "),k=0,d=e.length;k<d;k++)h+='<div style="font-family:'+e[k]+';">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n';
f.innerHTML=h+"</div>";document.body.appendChild(f);a.getFeatures();if(a.hasCanvas){window.scrollTo(0,10);h=document.querySelectorAll(".DescartesAppContainer");e=0;for(k=h.length;e<k;e++)h[e].parentNode.removeChild(h[e]);e=document.querySelectorAll("applet,ajs");k=/Descartes|DescartesJS|descinst.DescartesWeb2_0.class|Arquimedes|Discurso/i;h=[];d=0;for(var c=e.length;d<c;d++)k.test(e[d].getAttribute("code"))&&h.push(e[d]);e=0;for(k=h.length;e<k;e++)a.apps.push(new a.DescartesApp(h[e])),h[e].className=
"DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,0)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS,applet,ajs.DescartesJS,ajs{display:block;}";document.body.removeChild(f)}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};(function(){var a=document.getElementById("StyleDescartesApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel",
"stylesheet");a.innerHTML="applet.DescartesJS,applet,ajs.DescartesJS,ajs{display:none;}";document.head.appendChild(a)})();a.onResize=function(f){0<a.apps.length&&a.apps[0].scaleToFit()};var k={};a.onMessage=function(f){if(0<a.apps.length){var h=f.data;h&&("set"===h.type?"string"==typeof h.value||"number"==typeof h.value?a.apps[0].evaluator.setVariable(h.name,h.value):h.value&&void 0!=h.value.rows?a.apps[0].evaluator.matrices[h.name]=h.value:a.apps[0].evaluator.vectors[h.name]=h.value:"update"===h.type?
a.apps[0].update():"exec"===h.type?(f=a.apps[0].evaluator.getFunction(h.name))&&f.apply(a.apps[0].evaluator,h.value.toString().split(",")):"isResizeNeeded"===h.type?f.source.postMessage({type:"doResize"},"*"):"doResize"===h.type?0<a.apps.length&&a.apps[0].adjustSize():"change_config"===h.type&&(k[h.filename]?f=k[h.filename]:(f=document.createElement("div"),f.innerHTML=h.content,f=f.getElementsByTagName("param"),k[h.filename]=f),a.apps[0].children=f,a.apps[0].init()))}};void 0==a.loadLib&&(a.loadLib=
!0,window.addEventListener("load",h),window.addEventListener("message",a.onMessage),["webkitTransitionEnd","transitionend","oTransitionEnd","MSTransitionEnd"].forEach(function(f){window.addEventListener(f,function(f){a.onResize(f)})}));return a}(descartesJS||{});
